platform/win32.c
branchstable-1.0
changeset 1648 93b4c3bc6b9d
parent 1179 eea580b4e199
equal deleted inserted replaced
1390:60449ca1b00a 1648:93b4c3bc6b9d
   183  *  be NULL, and zero is returned.
   183  *  be NULL, and zero is returned.
   184  */
   184  */
   185 static int determineUserDir(void)
   185 static int determineUserDir(void)
   186 {
   186 {
   187     DWORD psize = 0;
   187     DWORD psize = 0;
   188     char dummy[1];
       
   189     BOOL rc = 0;
   188     BOOL rc = 0;
   190     HANDLE processHandle;            /* Current process handle */
   189     HANDLE processHandle;            /* Current process handle */
   191     HANDLE accessToken = NULL;       /* Security handle to process */
   190     HANDLE accessToken = NULL;       /* Security handle to process */
   192     LPFNGETUSERPROFILEDIR GetUserProfileDirectory;
   191     LPFNGETUSERPROFILEDIR GetUserProfileDirectory;
   193     HMODULE lib;
   192     HMODULE lib;
   215                 /*
   214                 /*
   216                  * Should fail. Will write the size of the profile path in
   215                  * Should fail. Will write the size of the profile path in
   217                  *  psize. Also note that the second parameter can't be
   216                  *  psize. Also note that the second parameter can't be
   218                  *  NULL or the function fails.
   217                  *  NULL or the function fails.
   219                  */
   218                  */
   220                 rc = GetUserProfileDirectory(accessToken, dummy, &psize);
   219                 rc = GetUserProfileDirectory(accessToken, NULL, &psize);
   221                 assert(!rc);  /* success?! */
   220                 assert(!rc);  /* success?! */
   222 
   221 
   223                 /* Allocate memory for the profile directory */
   222                 /* Allocate memory for the profile directory */
   224                 userDir = (char *) malloc(psize);
   223                 userDir = (char *) malloc(psize);
   225                 if (userDir != NULL)
   224                 if (userDir != NULL)