944,209 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 993
  • C++ RSS
Mar 20th, 2007
0

Loop help

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muhaa is offline Offline
9 posts
since Oct 2006
Mar 23rd, 2007
0

Re: Loop help

Connection? Like so:?

C++ Syntax (Toggle Plain Text)
  1. DWORD dwVal;
  2. BOOL bInternetExists = InternetGetConnectedState(&dwVal, 0);
  3. while(bInternetExists != TRUE)
  4. Sleep(100);
  5. // Do upload!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Queatrix is offline Offline
13 posts
since Mar 2007
Mar 23rd, 2007
0

Re: Loop help

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muhaa is offline Offline
9 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: strstr
Next Thread in C++ Forum Timeline: help using decimals in program





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC