There are several problems here, not the least of which is that you never call CreateThread() which means that your code is simply a subroutine of the main thread... and will block anything else in that thread until it's done.
Secondly the number of files and their names will have to come from a server someplace... this means you're going to have to poll the server for the next file... then the next, etc... until if finishes... There's going to have to be far more communication than is apparent here.
You're also going to run into a problem that if you're updating software Windows will not let you overwrite a running program.
So your update code is going to have to run in a completely separate executable.
I don't see even half of that in your samples.PHP Code:
get current program version...
contact server and get number of new files
while files pending
! get name of next file
! open file in temp folder
! download file
close with server
confirm accurate downloads
stop main program
copy files to program folder
clean up temp folder
restart main program
For the business of launching a thread...
This is just "air code" to show you the idea of how it works... don't even think about trying to compile it.
Code:// free running thead
DWORD WINAPI DoDownload(LPVOID Server)
{
DWORD good = 1;
INT FileCount;
CHAR FileName[MAX_PATH];
// get file count from server
FileCount = ContactServer((PCHAR) Server); // --- see typecast here...
if (! FileCount)
ExitThread(1); // signal completion if no files
InitializeProgressBar(FileCount)
while (FileCount)
{
GetNextFilename(FileName); // get next name from server
if ( ! Download(FileName) )
{
CloseServer();
CloseProgressBar()
ExitThread(0); // signal failure
}
UpdateProgressBar();
FileCount--;
}
CloseProgressBar();
ExitThread(1); // signal done
}
// initiator function
int GetUpdates( void ) // or as you need it
{
// confirm with user
// this launches the free running thread
hThread = CreateThread(NULL,0,DoDownload,(LPVOID) ServerName,0,NULL);
}