需要帮助将 Vb.Net 转换为 Delphi(API 内容(?))
Dim ThisModule As IntPtr
Dim Proc As Process() = Process.GetProcessesByName("Sol")
For i = 0 To Proc(0).Modules.Count - 1
If (Proc(0).Modules(i).ModuleName.ToString.Contains("UxTheme")) Then
ThisModule = Proc(0).Modules(i).BaseAddress
End If
Next
我已经制作了这段代码,并且工作完美,但是现在...我想在Delphi中制作它,问题是...我没有足够的知识来制作它,并且...在谷歌中,我还没有找到了我需要的信息。
提前致谢!。
Dim ThisModule As IntPtr
Dim Proc As Process() = Process.GetProcessesByName("Sol")
For i = 0 To Proc(0).Modules.Count - 1
If (Proc(0).Modules(i).ModuleName.ToString.Contains("UxTheme")) Then
ThisModule = Proc(0).Modules(i).BaseAddress
End If
Next
I have made this code, and works perfectly, but now... i want to make it in Delphi, the problem is... i have not the enough knowledge for make it, and... in google, i haven't found the information i need.
Thanks in advance!.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用较低级别的 API,即工具帮助 API。如何获取所需内容的基本概述如下:
CreateToolhelp32Snapshot()
并传递TH32CS_SNAPPROCESS
。Process32First()
和Process32Next()
遍历进程,直到找到所需的进程。CloseHandle()
关闭快照。CreateToolhelp32Snapshot()
,这次传递TH32CS_SNAPMODULE
和步骤 2 中找到的所需进程 ID。Module32First()
和 < code>Module32Next() 直到找到所需的模块。CloseHandle()
关闭快照。You need to use a lower level API, the tool help API. A basic outline of how to get what you need is as follows:
CreateToolhelp32Snapshot()
passingTH32CS_SNAPPROCESS
.Process32First()
andProcess32Next()
until you find the process you want.CloseHandle()
to close the snapshot.CreateToolhelp32Snapshot()
again, this time passingTH32CS_SNAPMODULE
and the desired process ID found in step 2.Module32First()
andModule32Next()
until you find the module you want.CloseHandle()
to close the snapshot.您可以使用具有此类库的免费模块 MadCollection (madKernel,如果我没记错的话)。编码非常接近OP的编码。 (我用它来向我的程序之一的父进程发送消息)。
编辑:
关于许可问题,请参阅 Madshi.net 许可协议页面的引用:
You could use the free modules form MadCollection (madKernel, if I'm not mistaken) which have such libraries. The coding are very near those of the OP. (I've used it to send messages to the parent process of one of my programs ).
EDIT:
About licensing troubles, see this quote from Madshi.net license agreement page: