i made a dll which is saving ur own game progress in a file.
now i also want to upload that file on a ftp server when the dll detaches the process.
is it possible to upload files when the dll is getting detached ?
i made it like this but it seems to dont work (getting the error of FtpPutFile when it fails)
Code:
... ofstream ofile; ofstream f; char dest[9999]; TCHAR NPath[MAX_PATH]; WIN32_FIND_DATA FindFileData; HINTERNET hOpen, hConnection; void upload(char *bla); BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ) { ... ... case DLL_PROCESS_DETACH: if(ofile) { GetCurrentDirectory(MAX_PATH, NPath); add_log("\n\n[Log Closed]"); ofile.close(); Sleep(500); FindFirstFile("./progress.txt", &FindFileData); sprintf_s(dest, "%s\\%s", NPath, FindFileData.cFileName); MessageBox(NULL, dest, "Test", NULL); upload(dest); break; } } return TRUE; } ... ... void upload(char *filepath) { hOpen = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); hConnection = InternetConnect(hOpen, "example.bplaced.net", INTERNET_DEFAULT_FTP_PORT, "usernameExample", "passwordExample", INTERNET_SERVICE_FTP, NULL, NULL); if(!(FtpPutFile(hConnection, filepath, "/progress.txt", FTP_TRANSFER_TYPE_BINARY, INTERNET_FLAG_PASSIVE))){ f.open("./Fehler.txt", ios::app); f << GetLastError() << endl; f.close(); }else{ MessageBox(NULL, "Successfully uploaded !", "Ftp Upload", NULL); } InternetCloseHandle(hConnection); InternetCloseHandle(hOpen); }
i hope u can help me