|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
kernel32.dll etc info on functions ?
Could anyone tell me where i can find the syntax and other info about these inherent windows libraries (kernel322.dll user32.dll etc) ?
The specific function i require is finding the memory start address and length of a program that is running in Windows NT. Currently i have the ability to get the process ID by using the FindWindow function, but this is just code pasted on to me. What i need is a resource that i can consult for this type of info. Thanks ps. i tried the microsoft site but it's not the most helpful of places ! [edit] It seems Microsoft dictates there is a difference between Windows NT and Windows 2000, it is Windows 2000 that i'm interested in. [/edit] Last edited by Mozo_Grand : March 1st, 2003 at 11:18 AM. |
|
#2
|
|||
|
|||
|
What kinds of info will you already have about the running program? Name? Gender...?
In the meantime, here are some helpful functions I've used many times in the past: Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Declare Function GetExitCodeProcess Lib "kernel32" _ (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function CreateProcess Lib "kernel32" _ Alias "CreateProcessA" _ (ByVal lpApplicationName As String, _ ByVal lpCommandLine As String, _ lpProcessAttributes As Any, _ lpThreadAttributes As Any, _ ByVal bInheritHandles As Long, _ ByVal dwCreationFlags As Long, _ lpEnvironment As Any, _ ByVal lpCurrentDriectory As String, _ lpStartupInfo As STARTUPINFO, _ lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function OpenProcess Lib "kernel32.dll" _ (ByVal dwAccess As Long, _ ByVal fInherit As Integer, _ ByVal hObject As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" _ (ByVal hProcess As Long, _ ByVal uExitCode As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long Const SYNCHRONIZE = 1048576 Const NORMAL_PRIORITY_CLASS = &H20& Private pInfo As PROCESS_INFORMATION Private sInfo As STARTUPINFO ' END OF DECLARATIONS Public Function RunProgram(sProgram As String, sProgramDir As String) Dim sNull As String Dim lSuccess As Long Dim lRetValue As Long sInfo.cb = Len(sInfo) lSuccess = CreateProcess(sNull, _ sProgram, _ ByVal 0&, _ ByVal 0&, _ 1&, _ NORMAL_PRIORITY_CLASS, _ ByVal 0&, _ sProgramDir, _ sInfo, _ pInfo) End Function Public Function IsRunning() As Boolean Dim nExitCode As Long Dim nn As Long IsRunning = True nn = GetExitCodeProcess(pInfo.hProcess, nExitCode) If nExitCode = 0 Then IsRunning = False End Function Public Function KillProgram() Dim lRetValue As Long lRetValue = TerminateProcess(pInfo.hProcess, 0&) lRetValue = CloseHandle(pInfo.hThread) lRetValue = CloseHandle(pInfo.hProcess) End Function Public Function ProgramProcess() As Long ProgramProcess = pInfo.hProcess End Property Public Function ProgramThread() As Long ProgramThread = pInfo.hThread End Property
__________________
- Chris of Custom Fit Technology http://www.customfittech.com Access to MySQL Conversion Tool, Visual XSLT Conversion Tool Last edited by customfittech : March 1st, 2003 at 09:49 PM. |
|
#3
|
|||
|
|||
|
thanks for the reply, lots of info !
what i'm particularly interested in is a resource where i can find out these things. I currently have a method to obtain some info which enables me to read memory contents but i need more info about how else i can use it. Declare Function ReadProcessMemory Lib "kernel32" (ByVal _ hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal _ nSize As Long, lpNumberOfBytesWritten As Long) As Long Declare Function GetWindowThreadProcessId Lib "user32" (ByVal _ hwnd As Long, lpdwProcessId As Long) As Long Declare Function OpenProcess Lib "kernel32" (ByVal _ dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal _ dwProcessId As Long) As Long Declare Function CloseHandle Lib "kernel32" (ByVal hObject As _ Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long Function ReadFloat(Offset As Long) thehwnd = FindWindow(vbNullString, "Prog_Name") GetWindowThreadProcessId thehwnd, ProcessId processhandle = OpenProcess(&H10, False, ProcessId) X = ReadProcessMemory(ByVal processhandle, ByVal Offset, _ nBuffer, 4, 0) ReadFloat = nBuffer CloseHandle processhandle End Function This code which i'm currently using contains a number of calls to outside functions in the kernel32 and user32 dll files. Where can i find out their parameters and a list of what other functions are available ? thanks Last edited by Mozo_Grand : March 4th, 2003 at 05:10 AM. |
|
#4
|
|||
|
|||
|
Oh sure, it's in Visual Studio X(6) Tools > API Text Viewer.
Also, I'm sure there are very good books on the subject. |
|
#5
|
||||
|
||||
|
|
|
#6
|
|||
|
|||
|
ok thanks, guess i must be being real stupid but there is no such item on my tools menu ! I can load an API viewer as an addin but that doesn't seem to be much help either and doesn't appear on the tools menu.
The google link lists several books so i guess i'll have to get ordering. Thanks both anyway for your help. |
|
#7
|
||||
|
||||
|
To get the api viewer into the add-ins menu, click on the Add-Ins menu, then click on Add-In Manager... option. This will bring up a dialog box that list all of the add-ins that you can add to the menu. A few entries down the list you will see an entry VB 6 API Viewer.
Click on it. In the Load Behaivor frame on the dialog in the lower right corner click the Loaded/Unloaded checkbox and the Load on Startup checkbox then click the OK button. This will put the API Viewer into your add-ins menu. Once you open the viewer, click on the File -> Load Text File... in the menu and select WIN32API.txt file. This will load the api declarations into the viewer for you. |
|
#8
|
|||
|
|||
|
Book on Win32 API
In my opinion, the best book on the subject of Windows APIs for VB programmers is Dan Appleman's aptly named Visual Basic Programmer's Guide to the Win32 API. I'm not sure how updated it is though - I think it's mostly VB6. It could probably be picked up used somewhere pretty cheaply though.
Desaware |
|
#9
|
|||
|
|||
|
ok thanks all, will see what i can find.
|
|
#10
|
|||
|
|||
|
You shouldn't need to buy any books, look for Miscrosoft's Win32.hlp file. Borland for example, bundles MS tech help files with their development tools. I don't use MS stuff much, but I'd expect them to do the same.
|
|
#11
|
|||
|
|||
|
|
|
#12
|
||||
|
||||
|
Although it is nice to see the link to the msdn library and the mention to the help file (fyi VS help is the msdn library) but if you would re-read the first post the Mozo_Grand stated that (s)he had already been to the microsoft site and didn't find it that helpfull. I would agree that the site is a good reference, but IMHO the poster is looking for something a little different.
|
|
#13
|
|||
|
|||
|
Quote:
Whatever. Is there a point you are trying to make, like don't bother to post or something?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#14
|
||||
|
||||
|
Yeah, there is a point. Read the thread before you post a response.
|
|
#15
|