帮忙改改下面代码(50分)

Z

zbird

Unregistered / Unconfirmed
GUEST, unregistred user!
//---------------------------<br>//帮忙改改下面代码,//我从C++代码改过来的,还有部分我不会改;谢谢<br>//----------------------------<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; hMod:HMODULE;<br>&nbsp; cbNeeded:DWORD;<br>&nbsp; buf:char;<br>&nbsp; hProcess:thandle;<br>&nbsp; pid:dword;<br>//假使process id是 pid 的话:<br>begin<br>&nbsp; hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,FALSE,pid);<br>&nbsp; if hProcess&lt;&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; if( EnumProcessModules( hProcess, &amp;hMod, sizeof( hMod ), &amp;cbNeeded ) ) &nbsp;then//这里[:(]<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; buf[MAX_PATH+1]='';<br>&nbsp; &nbsp; &nbsp; if(GetModuleBaseName( hProcess, hMod,buf,sizeof buf)&gt;0);<br>//<br>// buf放的就是名字<br>//<br>&nbsp; end;<br>&nbsp; CloseHandle(hProcess);<br>end;
 
if hProcess&lt;&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; if( EnumProcessModules( hProcess, &amp;hMod, sizeof( hMod ), &amp;cbNeeded ) ) &nbsp;then//这里<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; buf[MAX_PATH+1]='';<br>&nbsp; &nbsp; &nbsp; if(GetModuleBaseName( hProcess, hMod,buf,sizeof buf)&gt;0);<br>//<br>// buf放的就是名字<br>//<br>&nbsp; end;<br>改为:<br>if hProcess&lt;&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; if( EnumProcessModules( hProcess, @hMod, sizeof( hMod ), @cbNeeded )&lt;&gt;0 ) &nbsp;then//这里<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; buf[MAX_PATH+1]:='';<br>&nbsp; &nbsp; &nbsp; if(GetModuleBaseName( hProcess, hMod,buf,sizeof buf)&gt;0);<br>//<br>// buf放的就是名字<br>//<br>&nbsp; end;<br>
 
不太明白 楼上只加了个 ":"
 
itren:<br>楼上还改了“&amp;“ 为 “@“ 。仔细看[:)]<br>zbird:<br>那个代码将得到进程名。<br>如果想得到进程所用的module(dll,...)还有别的方法。<br>//-----<br>CIONO1
 
多人接受答案了。
 
顶部