I was working on this last night and today and figured i would release it, purhaps someone could use it in one of their [COLOR=red ! important][COLOR=red ! important]applications[/COLOR][/COLOR] to auto update.
You will notice that i download the demo file as TESTexe, then rename it once on the [COLOR=red ! important][COLOR=red ! important]pc[/COLOR][/COLOR] to TEST.exe. No this isnt because i dont think logical, its because if you direct download an [COLOR=red ! important][COLOR=red ! important]exe [COLOR=red ! important]file[/COLOR][/COLOR][/COLOR] some (nod32 and avast to name a few) antivirus systems detect it as a [COLOR=red ! important][COLOR=red ! important]virus[/COLOR][/COLOR] downloader through Heuristics scanning.
[BANANA]Source: http://www.psp-hacks.com/forums/about79699.html[/BANANA]Code:#include <stdio.h> // Header file with the C standard input and output functions #include <urlmon.h> // Header file with URLDownloadToFile function #pragma comment(lib, "urlmon.lib") // This library includes the URLDownloadToFile function void main() // Our main function, cant run without this ;) { char remVer[4]; // Variable to store remote version number char myVer[4] = "1.0"; // Set local version number printf("Checking for newer versions...\n"); // Ver.ini should have one line with the newest version (ie, 1.0) URLDownloadToFile(NULL, "http://www.console-world.org/Updates/Ver.ini", "Ver.ini", 0, 0); FILE *filePtr; // Create a file pointer filePtr = fopen("Ver.ini","r"); // Open Ver.ini from same dir as our program if(filePtr != NULL) // If the INI exists { fgets(remVer, 4, filePtr); // Read the INI data into our variable array printf("Remote Version: %s\n", remVer); // Display remote version info printf("Current Version: %s\n", myVer); // Display local version info fclose(filePtr); // Close the file stream } else // If the INI doesnt exist printf("\nCannot locate Ver.ini"); if (strcmp(myVer, remVer) == 0) // If the local version is the same as the remote version { printf("\nYou already have the newest version\n"); remove("Ver.ini"); // Delete Ver.ini, we no longer need its services :) } else // If the local version is NOT the same as the remote version { printf("\nYou are running an OLD version, Updating...\n"); remove("Ver.ini"); // Delete Ver.ini, we no longer need its services :) /* Here we must not direct download an EXE file or antivirus Heuristics detect as virus URLDownloadToFile(NULL, "http://www.console-world.org/Updates/TESTexe", "TESTexe", 0, 0); URLDownloadToFile(NULL, "http://www.console-world.org/Updates/TESTdll", "TESTdll", 0, 0); rename("TESTexe", "TEST.exe"); rename("TESTdll", "TEST.dll"); */ } printf("\nPress ENTER to continue"); // Tell the user how to exit fflush(stdin); // Flush the standard input getchar(); // Wait for user to press a key }







Reply With Quote