Reputation: 1111
What I want is to start my main application using my tiny LicenseExe application.
LicenseExe will check that whether this system is registered or not.
If the system is not registered, LicenseExe should be exit. If the system is registered, then LicenseExe will call ShellExecute or whatever method to execute the main application exe.
This is easy I can do this.
What I want is, my main application could never execute by directly double clicking on its exe file. It only execute by LicenseExe application. Is it possible?
This is a kind of trick to make my application licensed. So, please guide me. How can I stop executing my main application directly and make it dependent on my tiny LicenseExe application.
Main application should only be started from the LicenseExe application, not by double clicking and not even by command line.
I am using C++ Visual Studio 2010 under Windows 7 Platform.
Upvotes: 1
Views: 134
Reputation: 101
Create and lock a mutex in licence.exe [when the system is registered] : CreateMutexEx
Check the mutex in the main app. If the mutex is locked, main application should continue execution.
Else it should exit.
Upvotes: 1
Reputation: 53366
In main app, you can check for the parent process that has launched it. If its not LicenseExe then mainapp should exit.
Reference for this: How can a Win32 process get the pid of its parent?
Apart from this, the licenseExe can pass handles or environment variable to the mainapp while launching it. The mainapp can verify if such info is present and continue execution otherwise exit.
Upvotes: 5
Reputation: 4012
You could use the command line parameters in your main application. When it's started check for a set of arguments, and if they're not present - exit the application. Then, inside your LicenseExe, you could call the application with the given parameters, that only you know.
Example on a Windows system:
//main.cpp
int main(int argc, char* argv[]){
if(argc==2 && argv[1]=="f20ASD129d0saCZasa"){
// your normal app-code goes here
}
else return 0;
}
And the LicenseExe:
//LicenseExe.cpp
#include "systemRegisteredTest.h"
int main(){
if(systemIsLicensed())
system("yourMainApp.exe f20ASD129d0saCZasa");
else return 0;
}
Upvotes: 1
Reputation: 438
You can replace main application with dynamic link library (DLL).
DLL can be dynamically called by LinceseExe
as you want.
Upvotes: 2