Click to See Complete Forum and Search --> : Restrict user from installing another instance of the application


shalini_gupta
April 13th, 1999, 06:46 AM
Hello,

I have a specification to implement in my Setup:-

I want to customise setup to limit the user, so that he can install only one instance of the application on his machine. How can I restrict user from installing another instance of the application on his machine, if he re-runs the setup (from original location)?

Please help me out with any suggestion how to achieve above spec.

Thanks in advance,
Shalini Gupta

April 16th, 1999, 10:40 AM
Hi Shalini,

Step 1:
While installing your application for the first time, you can create a key in the registry
(usually it will be in HKEY_LOCAL_MACHINE\Software\Shalini_Gupta\Your Application)....

Step 2:
When the user tries to reinstall the application try to find the key in this case
HKEY_LOCAL_MACHINE\Software\Shalini_Gupta\Your Application and if the key is existing then
exit your setup without proceeding further...

Well, for registry operations there are set of Registry API's provided by Microsoft...

Hope this helps...

Feel free to contact me...
My email id is pugazh@usa.net

Bye
pugal

Samar Aarkotti
April 20th, 1999, 03:01 PM
hi,
All you got say is " hi Registry " ;-)
coz your application ID will be stored in the Registry in the HKEY_LOCAL ....

so in the startup of your program , open the registry key... and check for that particular ID ...if it is present then dont run your application.... it's that simple ....

Good Luck
the Ghost...
Aarkotti@hotmail.com

Joerg Nowak
April 27th, 1999, 12:53 PM
Hi There is another way to do this which I go out of Windows Developer Journal

It makes use of the InitInstance and ExitInstance routine in the CYourApp Class

BOOL CYourApp::InitInstance()
{
BOOL bAlreadyRunning=FALSE;
m_hMutexInstance=CreateMutex(NULL,FALSE,"Your");

if(GetLastError()==ERROR_ALREADY_EXISTS){
bAlreadyRunning=TRUE;
}
if(bAlreadyRunning==TRUE){
return FALSE;
}
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}

AfxEnableControlContainer();

// Standard initialization
}

int CYourApp::ExitInstance()
{
if(m_hMutexInstance!=NULL){
CloseHandle(m_hMutexInstance);
}
return CWinApp::ExitInstance();
}

If you haven't solved your problem, maybe this will Help