installshield卸载时提示重启动的原因以及解决办法

有时候卸载installshield安装的程序,卸载完会提示是否重启电脑以完成所有卸载,产生这个提示的常见原因有如下几种:

1. 卸载时,程序正处于运行状态

2. 卸载时,程序文件夹处于打开状态

3. 卸载时,有文件被别的进程调用,或者在进程中,常见情况如dll在进程中

一般来说解决办法是针对第三种情况的,解决办法是卸载时强制杀进程,比如在OnMaintUIBefore或者OnUninstall里写上强制杀进程的代码。对于第一种情况和第二种情况,如果是可交互的普通GUI程序,一般不予理会,因为这些行为是不能禁止的合理行为。


Installshield停止操作系统进程的代码 --IS6及以上版本适用

setup.rul的代码

installshield卸载时提示重启动的原因以及解决办法installshield卸载时提示重启动的原因以及解决办法Code

ShutDownRunningApp.rul的代码

installshield卸载时提示重启动的原因以及解决办法installshield卸载时提示重启动的原因以及解决办法Code

Installshield停止操作系统进程的代码--IS5版本适用

出处:http://www.installsite.org/pages/en/isp_ext.htm

这个地址上有不少好东西,有空要好好研究下

里面的“List and Shut Down Running Applications”就是演示了Installshield如何停止操作系统进程

installshield卸载时提示重启动的原因以及解决办法installshield卸载时提示重启动的原因以及解决办法Code/



//////////////////// installation declarations///////////////////



//----- DLL function prototypes -----



//your DLL function prototypes



//Custom function for shutting down MyApp process

prototype ShutDownApp();



//Custom function for shutting down any running application

prototype GetRunningApp( BYREF STRING );



///////////////////////////////////////////////////////////////////////////////////

//Dll function calls needed



//Kernel functions

prototype LONG Kernel32.OpenProcess( LONG, BOOL, LONG );//1ST Param = 2035711 for PROCESS_ALL_ACCESS (It pays to know hex!!), 2nd = Doesn't matter, 3rd = Process ID

prototype BOOL Kernel32.TerminateProcess( LONG, INT );//1st Param = Process ID, 2nd = Doesn't matter - "0"



//Process info functions

prototype LONG Psapi.EnumProcesses( POINTER, LONG, BYREF LONG );//1st Param = By ref, Process ID, 2nd = number of bytes in param 1 = "4", 3rd = cb needed - might as well be "4"

prototype LONG Psapi.GetModuleFileNameExA( LONG, LONG, POINTER, LONG );//1st Param = ProcessID, 2nd= Module ID, 3rd = pointer to a string, 4th = length of string

prototype LONG Psapi.EnumProcessModules( LONG, BYREF LONG, LONG, BYREF LONG );//1st Param = Process Handle, 2nd = Module Handle, 3rd = bytes passed ("4"), 4th = bytes needed ("4")

///////////////////////////////////////////////////////////////////////////////////



//your global variables

STRING svApp



program



if(1==GetRunningApp ( svApp ) ) then

MessageBox (
"The installation has detected that"+svApp+"is running."+

"Please close"+svApp+"then restart the installation process.", SEVERE );

abort;

endif;



if(0==ShutDownProjectManager() )gotoend_install;//This statement is within the Program block and jumps to the

"end_install:"switchifthe function fails.-WFS



endprogram



///////////////////////////////////////////////////////////////////////////////////

//

//Function: GetRunningApp

//

//Purpose: This function returns "1" if an app is running. Otherwise "0".

//If "1" is returned, the "appName" parameter will contain the name of the

//application running.

//

//Theron Welch 3/3/99

//

///////////////////////////////////////////////////////////////////////////////////

function GetRunningApp( appName )

HWND hWnd;

LONG ProcessIDs[
512];//An array that's hopefully big enough to hold all process IDs

LONG cbNeeded;

LONG cb;

LONG numItems;

LONG ProcessHandle;

LONG ModuleHandle;

LONG Count;

LONG Ret;

LONG Ret2;

POINTER pArray;
//This pointer will point at the array of process IDs

STRING ModuleName[128];

STRING FileName[
64];

POINTER pModuleName;

begin



UseDLL ( WINSYSDIR
^"Psapi.dll");//Load the helper dll - PsApi.dll



cbNeeded
=96;

cb
=8;



pArray
=&ProcessIDs;//Point at the array



while( cb<=cbNeeded )

cb
=cb2;

EnumProcesses ( pArray, cb, cbNeeded );
//Get the currently running process IDs

endwhile;

numItems
=cbNeeded/4;//Calculate number of process IDs - 4 is the size in bytes of a Process ID (DWORD)



forCount=1to numItems//For each process id



ProcessHandle
=OpenProcess (2035711,1, ProcessIDs[ Count ] );//Get a handle to the process

if(0!=ProcessHandle ) then



Ret
=EnumProcessModules ( ProcessHandle, ModuleHandle,4, cb );//Get the module handle - first one is EXE, the one I care about!

if(0!=Ret ) then



pModuleName
=&ModuleName;//Point at the array

Ret=GetModuleFileNameExA ( ProcessHandle, ModuleHandle, pModuleName,128);//Get the exe name

if(0!=Ret ) then



ParsePath ( FileName, ModuleName, FILENAME_ONLY );
//Convert the full path to a filename



//////////////////////////////Outlook/////////////////////////////////////////

//Copy the next 5 lines and customize for each app

Ret=StrCompare ( FileName,"Outlook");

if(0==Ret ) then//If there's a matchinstallshield卸载时提示重启动的原因以及解决办法

FileName="Microsoft Outlook";//Change to a name that makes senseinstallshield卸载时提示重启动的原因以及解决办法

appName=FileName;//Copy the filename to the passed in parameter (by ref)

return1;//Return "Found"

endif;

///////////////////////////////////////////////////////////////////////////////



//////////////////////////////Navwnt/////////////////////////////////////////

Ret=StrCompare ( FileName,"Navwnt");

if(0==Ret ) then//If there's a matchinstallshield卸载时提示重启动的原因以及解决办法

FileName="Norton Anti-Virus";//Change to a name that makes senseinstallshield卸载时提示重启动的原因以及解决办法

appName=FileName;//Copy the filename to the passed in parameter (by ref)

return1;//Return "Found"

endif;

///////////////////////////////////////////////////////////////////////////////

endif;

endif;

endif;

endfor;

return0;//"Well, uh, apparently, no application is runninginstallshield卸载时提示重启动的原因以及解决办法"

end;



///////////////////////////////////////////////////////////////////////////////////

//

//Function: ShutDownApp

//

//Purpose: This function attempts to shut down the app you decide on. It returns

//"1" if successful or if app is not running.

//Otherwise "0" if it could not be shut down. Install should terminate

//if "0" is returned.

//

//Theron Welch 3/3/99

//

///////////////////////////////////////////////////////////////////////////////////



function ShutDownApp()

HWND hWnd;

LONG ProcessIDs[
512];//An array that's hopefully big enough to hold all process IDs

LONG cbNeeded;

LONG cb;

LONG numItems;

LONG ProcessHandle;

LONG ModuleHandle;

LONG Count;

LONG Ret;

LONG Ret2;

POINTER pArray;
//This pointer will point at the array of process IDs

STRING ModuleName[128];

STRING FileName[
64];

POINTER pModuleName;

begin



UseDLL ( WINSYSDIR
^"Psapi.dll");//Load the helper dll - PsApi.dll



cbNeeded
=96;

cb
=8;



pArray
=&ProcessIDs;//Point at the array



while( cb<=cbNeeded )

cb
=cb
2;

EnumProcesses ( pArray, cb, cbNeeded );
//Get the currently running process IDs

endwhile;

numItems
=cbNeeded/4;//Calculate number of process IDs - 4 is the size in bytes of a Process ID (DWORD)



forCount=1to numItems//For each process id



ProcessHandle
=OpenProcess (2035711,1, ProcessIDs[ Count ] );//Get a handle to the process

if(0!=ProcessHandle ) then



Ret
=EnumProcessModules ( ProcessHandle, ModuleHandle,4, cb );//Get the module handle - first one is EXE, the one I care about!

if(0!=Ret ) then



pModuleName
=&ModuleName;//Point at the array

Ret=GetModuleFileNameExA ( ProcessHandle, ModuleHandle, pModuleName,128);//Get the exe name

if(0!=Ret ) then



ParsePath ( FileName, ModuleName, FILENAME );
//Convert the full path to a filename

//MessageBox( FileName, INFORMATION );

Ret=StrCompare ( FileName,"MYAPP~1.EXE");//Compare filenames (used for short file names. -WFS)

Ret2=StrCompare ( FileName,"MYAPP.exe");//Compare filenames

if(0==Ret||0==Ret2 ) then//If it's the filename I'm looking forinstallshield卸载时提示重启动的原因以及解决办法

Ret=TerminateProcess( ProcessHandle,0);//Terminate the process

if(0==Ret ) then

gotoError;

endif;

gotoQuit;

endif;



endif;



endif;



endif;



endfor;



Quit:



UnUseDLL (
"Psapi.dll");//Unload the helper dll - PsApi.dll

return1;//Happy



Error:



UnUseDLL (
"Psapi.dll");//Unload the helper dll - PsApi.dll

return0;//Sad



end;
原文链接: https://www.cnblogs.com/BeyondTechnology/archive/2010/10/14/1851712.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/16142

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月7日 下午4:18
下一篇 2023年2月7日 下午4:20

相关推荐