Hi,
Happy new year!
I try to wrap some API methods using NativeBoost to access Win32 Registry and
broaden the Pharo support
for Windows. Currently I'm already able to
- create registry keys (RegCreateKeyA API)
- open registry keys (RegOpenKeyExA API)
- delete registry keys (RegDeleteKeyA API)
- close registry key handles (RegCloseKey API)
Now I additionally want to query some keys using the "RegQueryValueExA" API
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms724911%28v=vs.85%29.aspx).
As I tried an example in an elder Smalltalk/MT first (see attached) I know it
is working from the Win32 API
side.
My NativeBoost definition in Pharo for wrapping the function looks like this
(similar to MSDN):
regQueryValueExA: hKey with: lpValueName with: lpReserved with: lpType with:
lpData with: lpcbData
<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin'>
^ self nbCall: #(LONG RegQueryValueExA(
HKEY hKey,
LPCTSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData)) module: #advapi32
But when I call it I get a "Generic error" thrown by NB and independent how
hard I try I can not
get this call to work in NativeBoost. I checked all arguments, checked the type
definitions (pool WinTypes
which is similar to NBWinTypes), played with options, ... but was not able to
find out what I'm doing wrong
in Pharo. Meanwhile after investing several days of my spare time it looks like
I cant "see the wood because of
all the trees".
I would really appreciate if someone with enough knowledge of NativeBoost could
have a second look
to point my into the right direction.
To reproduce:
=============
- use a fresh Pharo4.0 Latest update: #40428
- open World menu -> Configuration Browser and load "OSWindows" project
- go to class WinRegistry
- there is the NativeBoost API definition in method
#regQueryValueExA:with:with:with:with:with:
- and a method #example2 that calls this in a similar way as in my
Smalltalk/MT example
(if you try this example you get the "Generic error")
Many thanks in advance!
Bye
T.
|hkResult dwType lSize|
hkResult := Handle new.
(WINAPI RegOpenKeyEx: HKEY_LOCAL_MACHINE
with: 'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0'
with: NULL
with: KEY_QUERY_VALUE
with: hkResult basicAddress).
dwType := LONG new.
lSize := LONG new.
WINAPI RegQueryValueEx: hkResult
with: 'VendorIdentifier'
with: NULL
with: dwType basicAddress
with: NULL
with: lSize basicAddress