how to disable a program (dll) using a website?

Posts 1–3 of 3 · Page 1 of 1
how to disable a program (dll) using a website?
I have this doubt, it is possible to disable my program that is a dll using a check if it should work or be disabled.

example:

website to check and txt or other:
http://www.mpgh.net/myprogram.txt

inside of myprogram.txt:

it checks if it is written in txt:

program is online

it allows the operation.

if inside is written offline it disables

program is offline

how can I create this function?
Why would you do it from a website? Why not just make a server.

Beginning Winsock Programming - Simple TCP server - CodeProject

Go through that and learn Winsock, then you can create a server application that runs on your computer and the clients can connect to your computer and when the connection is made you can have the server tell the client "Online" or something like that.

It also allows for you to create a full interface for your server. Example if you wanted the clients to have a login or something, or to check for multiple connections from the same account, can all be done with winsock.

Hope I holped,
~lilneo
If he only needs to check that one thing for some reason it's a lot of hassle to learn Winsock (and not really needed to run a server constantly on your own machine).

Here's a quick way of doing exactly what you're asking for - it's neater to do it with curl or something similar but this does the trick without external wrappers. Modify it to your source:

Code:
#include <shlobj.h>
//You have to include shlobj.h

void Check(string url)
{
typedef int * (*URLDownloadToFileA)(void*,const char*,char*,DWORD,void*);
HINSTANCE LibHnd = LoadLibrary("Urlmon.dll");
URLDownloadToFileA URLDownloadToFile =  (URLDownloadToFileA) GetProcAddress(LibHnd,"URLDownloadToFileA");

URLDownloadToFile(0, url.c_str(), "check.txt", 0, 0);
}
Just make sure the url is defined somewhere and call the function from main or wherever you're doing it:

Code:
string link = "http://my.site.net/check.txt";
Check(link);
And checking the file you downloaded is just basic file I/O. If you don't know this, quick example:

Code:
//You need to include fstream and string for this

string mytext;
ifstream in;
in.open("check.txt");

if(!in){
cout << "Failed to open file for some reason...";
return 1;
}

getline(in, mytext);
in.close();

if(mytext.find ("program is offline") != string::npos)
{
//disable/exit, whatever you wanted to do)
}

//continue doing whatever the dll does
Alright you should really check that the file was actually downloaded and so on because otherwise it might still be in the cache and the program wouldn't notice if it failed to download but I'm writing most of this from the top of my head, google UrlDownloadToFileA and you can find how to do it.

It should also be added that this is not a safe way of checking anything, for example a malicious user could easily modify and lock "check.txt" to prevent you from downloading a new copy, your program would just read whatever the user put in it. Unless you simply disable it by checking return value of the download and exits if it failed.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us