Loop help

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Loop help

 
0
  #1
Mar 20th, 2007
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.
:rolleyes:

[PHP]

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

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


int Upload(char *localFile, char *remoteFile){
HINTERNET iSession;
HINTERNET iConnect;

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


InternetCloseHandle(iConnect);
InternetCloseHandle(iSession);

return 0;
}

int main(void)
{

Upload("C:\\1.jpg","1.jpg");

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

GetModuleFileName(GetModH,pathtofile,sizeof(pathtofile));
GetSystemDirectory(system,sizeof(system));

strcat(system,"\\test.exe");

CopyFile(pathtofile,system,false);


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));

RegCloseKey(hKey);

return 0;
}

[/PHP]
Last edited by muhaa; Mar 20th, 2007 at 9:12 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 13
Reputation: Queatrix is an unknown quantity at this point 
Solved Threads: 1
Queatrix Queatrix is offline Offline
Newbie Poster

Re: Loop help

 
0
  #2
Mar 23rd, 2007
Connection? Like so:?

  1. DWORD dwVal;
  2. BOOL bInternetExists = InternetGetConnectedState(&dwVal, 0);
  3. while(bInternetExists != TRUE)
  4. Sleep(100);
  5. // Do upload!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Re: Loop help

 
0
  #3
Mar 23rd, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 912 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC