是这样的,我在卸载SQL SERVER 7.0的时候说是这个EXE在运行,要我把它关掉,所以就有上面提到的问题了,是不是和SQL有关呢?
var lppe:tprocessentry32; sshandle:thandle; hh:hwnd; found:boolean; begin sshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0); found:=process32first(sshandle,lppe); while found do begin //进行你的处理其中lppe.szExefile就是程序名。 if uppercase(extractfilename(lppe.szExeFile))='PROJECT2.EXE' then begin hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID); TerminateProcess(hh,0); end; found:=process32next(sshandle,lppe); end; end; ******************** HANDLE hProcess Windows NT/2000: The handle must have PROCESS_TERMINATE access. For more information, see Process Security and Access Rights. 所以要先使用 DWORD SetSecurityInfo( HANDLE handle, // handle to object SE_OBJECT_TYPE ObjectType, // object type SECURITY_INFORMATION SecurityInfo, // buffer PSID psidOwner, // new owner SID PSID psidGroup, // new primary group SID PACL pDacl, // new DACL PACL pSacl // new SACL );
若你用win2000分区是ntfs,那dos根本就不认分区,那怎么干。
如没其它方法,就把你的硬盘接到其它的win2000的机子上(反正就要能认你硬盘分区的),重启在其它的机子上把它删掉吧。
lppe:tprocessentry32;
sshandle:thandle;
hh:hwnd;
found:boolean;
begin
sshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);
found:=process32first(sshandle,lppe);
while found do
begin
//进行你的处理其中lppe.szExefile就是程序名。
if uppercase(extractfilename(lppe.szExeFile))='PROJECT2.EXE' then
begin
hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);
TerminateProcess(hh,0);
end;
found:=process32next(sshandle,lppe);
end;
end;
********************
HANDLE hProcess
Windows NT/2000: The handle must have PROCESS_TERMINATE access.
For more information, see Process Security and Access Rights. 所以要先使用
DWORD SetSecurityInfo(
HANDLE handle, // handle to object
SE_OBJECT_TYPE ObjectType, // object type
SECURITY_INFORMATION SecurityInfo, // buffer
PSID psidOwner, // new owner SID
PSID psidGroup, // new primary group SID
PACL pDacl, // new DACL
PACL pSacl // new SACL
);