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.

71 lines
1.6 KiB

  1. //-------------------------------------------------------------------------
  2. //
  3. // Microsoft OLE
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: main.cxx
  7. //
  8. // Contents: DBCS enabled OLE storage
  9. //
  10. // History: 11/05/97 BogdanT created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <dfheader.hxx>
  14. #pragma hdrstop
  15. #include <dbcs.hxx>
  16. #include <locale.h>
  17. DH_DEFINE;
  18. int __cdecl main(int argc, char *argv[])
  19. {
  20. HRESULT hr = S_OK;
  21. UINT nCount = 0;
  22. LPTSTR ptszName = NULL;
  23. LPWSTR pwszName = NULL;
  24. LPSTORAGE pIStg = NULL;
  25. DH_FUNCENTRY(NULL, DH_LVL_TRACE1, _TEXT("main"));
  26. CDBCSStringGen dbcsgen;
  27. if(argc < 2)
  28. {
  29. printf("Usage: dbcstest <number of string>");
  30. exit(1);
  31. }
  32. dbcsgen.Init(0);
  33. for(nCount = atoi(argv[1]); nCount>0; nCount--)
  34. {
  35. hr = dbcsgen.GenerateRandomFileName(&ptszName);
  36. hr = TStrToWStr(ptszName, &pwszName);
  37. DH_HRCHECK(hr, TEXT("TStrToWStr")) ;
  38. if(S_OK != hr)
  39. break;
  40. hr = StgCreateDocfile(pwszName,
  41. STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
  42. 0,
  43. &pIStg);
  44. DH_HRCHECK(hr, TEXT("StgCreateDocfile"));
  45. if(S_OK != hr)
  46. break;
  47. pIStg->Release();
  48. _tprintf(TEXT("%s\n"), ptszName);
  49. delete[] ptszName;
  50. delete[] pwszName;
  51. }
  52. return (int)hr;
  53. }