Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running .EXE on a network
Message
From
06/03/2008 16:51:54
 
 
To
06/03/2008 11:55:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Vista
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01299335
Message ID:
01299548
Views:
14
>Hello,
>
>I have an application located on a server, where some workstations run the application's exe from its desktop shorcut of the executable on the server.
>
>How would I know how many workstations are running the application's exe on the server at a certain time? or if that application's exe is running more than once?
>
>Bob

Hi Bob

We use InstallShield to install our updates. Here is a small DLL I wrote to do something similar
// IsMyAppRunning.cpp : Defines the entry point for the DLL application.
// This DLL is called from an InstallShield install as an Express Extension

#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

CHAR WINAPI ISMyAppRunning( HWND hwnd, 
					LPSTR szSrcDir, 
					LPSTR szSupport, 
					LPSTR szInst, 
					LPSTR szRes
					)
{
	HANDLE hFile; 
	char szTmp[1024];
	char szExe[1024];

	wsprintf(szExe, "%s\\%s", szInst, "MyApp.EXE");

	hFile = CreateFile(szExe,     // file to create
		GENERIC_WRITE,			     // open for writing
		0,                            // do not share
		NULL,                         // default security
		OPEN_EXISTING,                // Opens the file. Fails if the file does not exist
		FILE_ATTRIBUTE_NORMAL |       // normal file
		FILE_FLAG_OVERLAPPED,         // asynchronous I/O
		NULL);                        // no attr. template

	if (hFile == INVALID_HANDLE_VALUE) 
	{
		wsprintf(szTmp, "MyApp appears to be running.  Close all instances of MyApp and try again.");
		MessageBox(GetFocus(), szTmp, "MyApp Upgrade failed", MB_OK);
		return (0);	
	}
	else
	{
		CloseHandle(hFile);
		return (1);
	}

}
Basically, it attempts to create a file with the same name as my exe. If it can, I can go ahead with the upgrade. If not, I know the exe is in use.

Bruce
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform