Hello,
I have tried to use JNAerator on the WinReg.h of the Windows SDK to
create an access to Registry functions. somehow this doesn't work as I
expect.
It looks like JNAerator is ignoring #include statements.
Trying it with WinReg.h alone it is producing very few code and
complains about undeclared types like WINAPI and such. I can progress
a little further when adding these missing defines and types manually
to the header file, but I feel like this is not the right approach.
Can someone help me to get this working? a little walkthrough? I'm not
that firm with C++, my world is Java, but of course I can handle basic
instructions involving M$ Visual Studio or such...
Thank you for caring for me :)
> To parse WinReg.h you'll need two files : config.jnaerator and GUID.h
> (attached to this message).
> The first contains the "command line" arguments needed by JNAerator,
> and the second is a hack to force the definition of the GUID struct
> (I'm still investigating why this hack is needed).
I did so, just slightly modification for the paths to the includes,
library and package name
> First, build JNAerator from sources to get my latest fixes :
> http://code.google.com/p/nativelibs4java/wiki/Build
> Then, put the two attached files in some directory and launch
> JNAerator in this directory (it will pick up config.jnaerator
> automatically) :
>
> java -jar
> libraries/jnaerator/jnaerator/target/jnaerator-0.9.5-SNAPSHOT-shaded.jar
>
> You'll get a neat WinReg.jar file (look inside the .jnaerator file for
> more options).
>
So far yes, I got the jar, and it doesn't look too bad. But the output
from JNAerator still looks suspicious that there is something not
working perfect. Do you think I should ignore this or is there something
I forgot?
Cheers,
Kai
C:\Programme\JNAerator>java -jar jnaerator-0.9.5-SNAPSHOT-shaded.jar
31.07.2010 00:02:34 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] ProgramFiles=C:\Programme
31.07.2010 00:02:34 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_HOME=C:\Programme\Microsoft Visual
Studio 9.0
31.07.2010 00:02:34 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] ProgramFiles=C:\Programme
31.07.2010 00:02:34 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] WINDOWS_SDK_HOME=C:\Programme\Microsoft
SDKs\Windows\v7.1
31.07.2010 00:02:34 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_INCLUDES=C:\Programme\Microsoft Visual
Studio 9.0\VC\include;C:\Programme\Microsoft SDKs\Windows\v7.1\Include
Struct with no field : XSAVE_AREA
Struct with no field : CONTEXT_EX
Struct with no field : TOKEN_USER
Struct with no field : TOKEN_MANDATORY_LABEL
Struct with no field : TOKEN_CONTROL
Struct with no field : TOKEN_ORIGIN
Struct with no field : JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
Struct with no field : IMAGE_ROM_HEADERS
Struct with no field : TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION
Struct with no field : FILE_ALLOCATION_INFO
Struct with no field : FILE_END_OF_FILE_INFO
Struct with no field : FILE_IO_PRIORITY_HINT_INFO
Struct with no field : MAT2
Struct with no field : POINTFX
Struct with no field : ENUMLOGFONTEXDVA
Struct with no field : ENUMLOGFONTEXDVW
Struct with no field : ENUMTEXTMETRICA
Struct with no field : ENUMTEXTMETRICW
Struct with no field : tagABORTPATH
Struct with no field : EMRSETCOLORADJUSTMENT
Struct with no field : tagEMRLINETO
Struct with no field : EMROFFSETCLIPRGN
Struct with no field : tagEMRFILLPATH
Struct with no field : tagEMREXCLUDECLIPRECT
Struct with no field : tagEMRSETVIEWPORTORGEX
Struct with no field : tagEMRSETVIEWPORTEXTEX
Struct with no field : EMRSETWORLDTRANSFORM
Struct with no field : tagEMRELLIPSE
Struct with no field : EMRROUNDRECT
Struct with no field : tagEMRARC
Struct with no field : EMRPIXELFORMAT
Struct with no field : MINMAXINFO
Struct with no field : WINDOW_BUFFER_SIZE_RECORD
Struct with no field : SERVICE_TIMECHANGE_INFO
----------
1. ERROR in file:\\\win32\advapi32\SERVICE_FAILURE_ACTIONSW.java (at line 4)
import win32.advapi32.Advapi32Library.SC_ACTION;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.SC_ACTION cannot be resolved
----------
----------
2. WARNING in file:\\\win32\advapi32\Advapi32Library.java (at line 3)
import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper is
never used
----------
----------
3. ERROR in file:\\\win32\advapi32\SERVICE_FAILURE_ACTIONSA.java (at line 4)
import win32.advapi32.Advapi32Library.SC_ACTION;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.SC_ACTION cannot be resolved
----------
----------
4. ERROR in file:\\\win32\advapi32\UPDATELAYEREDWINDOWINFO.java (at line 3)
import win32.advapi32.Advapi32Library.BLENDFUNCTION;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.BLENDFUNCTION cannot be resolved
----------
5. ERROR in file:\\\win32\advapi32\UPDATELAYEREDWINDOWINFO.java (at line 5)
import win32.advapi32.Advapi32Library.POINT;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.POINT cannot be resolved
----------
6. ERROR in file:\\\win32\advapi32\UPDATELAYEREDWINDOWINFO.java (at line 6)
import win32.advapi32.Advapi32Library.RECT;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.RECT cannot be resolved
----------
7. ERROR in file:\\\win32\advapi32\UPDATELAYEREDWINDOWINFO.java (at line 7)
import win32.advapi32.Advapi32Library.SIZE;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import win32.advapi32.Advapi32Library.SIZE cannot be resolved
To parse WinReg.h you'll need two files : config.jnaerator and GUID.h (attached to this message).
The first contains the "command line" arguments needed by JNAerator, and the second is a hack to force the definition of the GUID struct (I'm still investigating why this hack is needed).
First, build JNAerator from sources to get my latest fixes : http://code.google.com/p/nativelibs4java/wiki/Build
Then, put the two attached files in some directory and launch JNAerator in this directory (it will pick up config.jnaerator automatically) :
java -jar libraries/jnaerator/jnaerator/target/jnaerator-0.9.5-SNAPSHOT-shaded.jar
You'll get a neat WinReg.jar file (look inside the .jnaerator file for more options).
LONG WINAPI RegOpenKeyEx( __in HKEY hKey, __in_opt LPCTSTR lpSubKey, __reserved DWORD ulOptions, __in REGSAM samDesired, __out PHKEY phkResult );
(see
http://msdn.microsoft.com/en-us/library/ms724897%28v=VS.85%29.aspx)
I'm not exactly sure how to create the HKEY object. For the
beginning I would like to create one of the predefined HKEYS, for
example HKEY_CLASSES_ROOT, which has the static handle 0x80000001.
How do I initialize that properly?
In an earlier jnaeration I had a signature that accepted an int
instead of a PointerType, and that was returning successful (0) on
calls to the method above. With this PointerType HKEY my calls
always return error code 6, invalid handle.
the original signature is
LONG WINAPI RegOpenKeyEx( __in HKEY hKey, __in_opt LPCTSTR lpSubKey, __reserved DWORD ulOptions, __in REGSAM samDesired, __out PHKEY phkResult );(see http://msdn.microsoft.com/en-us/library/ms724897%28v=VS.85%29.aspx)
I'm not exactly sure how to create the HKEY object. For the beginning I would like to create one of the predefined HKEYS, for example HKEY_CLASSES_ROOT, which has the static handle 0x80000001.
How do I initialize that properly?
In an earlier jnaeration I had a signature that accepted an int instead of a PointerType, and that was returning successful (0) on calls to the method above. With this PointerType HKEY my calls always return error code 6, invalid handle.