| | |
Loop help
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 9
Reputation:
Solved Threads: 0
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]
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.
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Solved Threads: 1
Connection? Like so:?
C++ Syntax (Toggle Plain Text)
DWORD dwVal; BOOL bInternetExists = InternetGetConnectedState(&dwVal, 0); while(bInternetExists != TRUE) Sleep(100); // Do upload!
![]() |
Similar Threads
- Help with gui loop. (C)
- Loop...without the loop (Java)
Other Threads in the C++ Forum
- Previous Thread: strstr
- Next Thread: help using decimals in program
Views: 912 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





