Reputation: 185
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!.
Upvotes: 1
Views: 525
Reputation: 3820
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.
Upvotes: 1
Reputation: 612794
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()
passing TH32CS_SNAPPROCESS
.Process32First()
and Process32Next()
until you find the process you want.CloseHandle()
to close the snapshot.CreateToolhelp32Snapshot()
again, this time passing TH32CS_SNAPMODULE
and the desired process ID found in step 2.Module32First()
and Module32Next()
until you find the module you want.CloseHandle()
to close the snapshot.Upvotes: 2