Hi all i was wondering if any one could help me i have a program i made using wininet in c c++ and my program is not seeing if there is a connections before completing with the execution ive tried to get it sorted but cant seam to figure it out i was guna use a loop and just make the program start over and over again till it finds a connection here is what ive got so far any help would be much apriciated.
Here is what ive got so far im verry new to c c++ but im trying to learn some stuff the program uploads to our ftp server a jpg file of screen shot from punk buster.I had to add it to the reg just incase we need to reboot our game server.This is what i have so far.

#include <stdio.h>
#include <wininet.h>

#define server "test"
#define user "test"
#define pass "test"

int Upload(char *localFile, char *remoteFile){
iSession = InternetOpen("Explorer" , INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
iConnect = InternetConnect ( iSession, server, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0);
if(TRUE==FtpPutFile( iConnect, localFile, remoteFile, FTP_TRANSFER_TYPE_BINARY, 0))

    printf("Success");//I need this to just carry on exe

    else printf("Error!");//Im trying to get this to loop till conection is found

return 0;

int main(void)

char system[MAX_PATH];
char pathtofile[MAX_PATH];
HMODULE GetModH = GetModuleHandle(NULL);




HKEY hKey;

RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_SET_VALUE,&hKey );

RegSetValueEx(hKey, "Writing to the Registry Example",0,REG_SZ,(const unsigned char*)system,sizeof(system));


 return 0;

Connection? Like so:?

DWORD dwVal;               
BOOL bInternetExists = InternetGetConnectedState(&dwVal, 0);     
while(bInternetExists != TRUE)
// Do upload!

Yes but haw would i intergrate ur code with mine to get it to work every way ive tried i end up eating all the sys resources can some one show me haw i could impament some thing into my code thanx.