Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.0 KiB

  1. #include "pch.h"
  2. #include <stdio.h>
  3. void FillPropSet(IPersistFile *pfile, char *filename)
  4. {
  5. WCHAR wszbuffer[MAX_PATH];
  6. WIN32_FIND_DATAA findinfo;
  7. HANDLE hFile = FindFirstFileA(filename, &findinfo);
  8. if (hFile != INVALID_HANDLE_VALUE)
  9. {
  10. MultiByteToWideChar(CP_ACP, 0, findinfo.cFileName, -1, wszbuffer, MAX_PATH);
  11. pfile->Load(wszbuffer, STGM_READ);
  12. FindClose(hFile);
  13. }
  14. }
  15. void PlayWithPropertySetStorage(IPropertySetStorage *ppss)
  16. {
  17. IEnumSTATPROPSETSTG *penum;
  18. char buffer[MAX_PATH];
  19. if (SUCCEEDED(ppss->Enum(&penum)))
  20. {
  21. STATPROPSETSTG statpss;
  22. IPropertyStorage *pps;
  23. int i=0;
  24. while (penum->Next(1, &statpss, NULL) == S_OK)
  25. {
  26. printf("Property Storage %i:\n", ++i);
  27. if (SUCCEEDED(ppss->Open(statpss.fmtid,
  28. STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &pps)))
  29. {
  30. PROPSPEC spec;
  31. PROPVARIANT pvar;
  32. STATPROPSTG statps;
  33. IEnumSTATPROPSTG *penumprop;
  34. if (SUCCEEDED(pps->Enum(&penumprop)))
  35. {
  36. while (penumprop->Next(1, &statps, NULL)== S_OK)
  37. {
  38. spec.lpwstr = statps.lpwstrName;
  39. spec.propid = statps.propid;
  40. spec.ulKind = PRSPEC_PROPID;
  41. if (pps->ReadMultiple(1, &spec, &pvar) == S_OK)
  42. {
  43. if (spec.ulKind == PRSPEC_LPWSTR)
  44. WideCharToMultiByte(CP_ACP, 0, spec.lpwstr, -1, buffer, MAX_PATH, NULL, NULL);
  45. else
  46. buffer[0] = 0;
  47. printf(" prop %i (%s) = \"??\"\n", spec.propid, buffer);
  48. }
  49. }//While
  50. penumprop->Release();
  51. }
  52. pps->Release();
  53. }//While
  54. }
  55. penum->Release();
  56. }
  57. }
  58. EXTERN_C int __cdecl main(int argc, char **argv)
  59. {
  60. if (SUCCEEDED(CoInitialize(0)))
  61. {
  62. HRESULT hr;
  63. IPropertySetStorage *ppss;
  64. hr = CoCreateInstance(CLSID_MediaProperties, 0, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IPropertySetStorage, &ppss));
  65. if (SUCCEEDED(hr))
  66. {
  67. printf(("CoCreated the Storage\n"));
  68. if(argc>1)
  69. {
  70. IPersistFile *pfile;
  71. if (SUCCEEDED(ppss->QueryInterface(IID_PPV_ARG(IPersistFile, &pfile))))
  72. {
  73. FillPropSet(pfile, argv[1]);
  74. pfile->Release();
  75. }
  76. }
  77. PlayWithPropertySetStorage(ppss);
  78. ppss->Release();
  79. }
  80. else
  81. printf(("Failed to CoCreate the Storage: hr = %8x\n"), hr);
  82. CoUninitialize();
  83. }
  84. return 0;
  85. }