需要帮助将 Vb.Net 转换为 Delphi(API 内容(?))

发布于 2024-11-06 03:33:32 字数 422 浏览 0 评论 0原文

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一直都在从未离去 2024-11-13 03:33:32

您需要使用较低级别的 API,即工具帮助 API。如何获取所需内容的基本概述如下:

  1. 调用 CreateToolhelp32Snapshot() 并传递 TH32CS_SNAPPROCESS
  2. 接下来使用 Process32First()Process32Next() 遍历进程,直到找到所需的进程。
  3. 调用CloseHandle()关闭快照。
  4. 再次调用 CreateToolhelp32Snapshot(),这次传递 TH32CS_SNAPMODULE 和步骤 2 中找到的所需进程 ID。
  5. 使用 Module32First() 和 < code>Module32Next() 直到找到所需的模块。
  6. 调用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:

  1. Call CreateToolhelp32Snapshot() passing TH32CS_SNAPPROCESS.
  2. Next walk the processes with Process32First() and Process32Next() until you find the process you want.
  3. Call CloseHandle() to close the snapshot.
  4. Call CreateToolhelp32Snapshot() again, this time passing TH32CS_SNAPMODULE and the desired process ID found in step 2.
  5. Walk the modules with Module32First() and Module32Next() until you find the module you want.
  6. Call CloseHandle() to close the snapshot.
此刻的回忆 2024-11-13 03:33:32

您可以使用具有此类库的免费模块 MadCollection (madKernel,如果我没记错的话)。编码非常接近OP的编码。 (我用它来向我的程序之一的父进程发送消息)。

编辑:
关于许可问题,请参阅 Madshi.net 许可协议页面的引用:

免费软件产品

软件包“madBasic”、“madKernel”、“madShell”
并且“madSecurity”可以自由使用
对于非商业和商业
使用,无需购买许可证,
前提是:

(1) 作者
马蒂亚斯·劳恩 (Mathias Rauen) 获得应有的荣誉
为了他的工作。

(2) 被许可人确实
不声称该库是编写的
由他。

(3) 如果软件被修改,任何包含修改的软件必须在显着位置注明
修改产品或文档

 (a) 已被修改,

  (b) 进行修改的个人或实体的身份

 (c) 进行修改的日期。

(4) 上述包裹不得转让给任何第三方,除非
该第三方收到本协议的副本并同意受其约束
遵守其所有条款和条件。

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:

FREEWARE PRODUCT(S)

The packages "madBasic", "madKernel", "madShell"
and "madSecurity" may be used freely
for both non-commercial and commercial
use, without buying a license,
provided that:

(1) The author
Mathias Rauen is given proper credit
for his work.

(2) The licensee does
not claim that the library was written
by him.

(3) If the software is modified, any software containing modifications must prominently state in the
modified product or documentation

  (a) that it has been modified,

  (b) the identity of the person or entity that made the modifications

and

  (c) the date the modifications were made.

(4) The mentioned packages must not be transferred to any third party unless
such third party receives a copy of this agreement and agrees to be bound
by all of its terms and conditions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文