In my c/c++ header file there exists these parameters.
/* ErrorCode */
extern __declspec(dllimport) char * HL_ADAPTIVE_VIEWPORT;
extern __declspec(dllimport) char * HL_BACK;
extern __declspec(dllimport) char * HL_BUTTON1_STATE;
extern __declspec(dllimport) char * HL_BUTTON2_STATE;
[DllImport("hl", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern string HL_ADAPTIVE_VIEWPORT;
I can freely change string to whatever I choose but thats not the issue, the issue is that I cannot extern or use DLLImport for anything else other than a Method
These are usually constants.
But how can I dllimport those constands from the DLL File I have checked the DLL
| Function Name | Address | Relative Address | Ordinal | Filename |
|---|---|---|---|---|
| HL_ADAPTIVE_VIEWPORT | 0x1010f148 | 0x0010f148 | 4 (0x4) | hl.dll |
| HL_BACK | 0x1010f164 | 0x0010f164 | 5 (0x5) | hl.dll |
| HL_BUTTON1_STATE | 0x1010f090 | 0x0010f090 | 6 (0x6) | hl.dll |
| HL_BUTTON2_STATE | 0x1010f278 | 0x0010f278 | 7 (0x7) | hl.dll |
I am really stuck.. HJow can we dllimport declarations saved in the DLL
Thanks in advance

Interop Declarations problem
shangan
You can only use DllImport on functions. In order to access a global pointer you'll have to expose a function in unmanaged code to get or set the value. Alternatively you could use C++/CLI to interact with the global variable. Note that once you have access to the actual pointer value then you can get and set the underlying memory with Marshal.PtrToStringAnsi or Marshal.StringToHGlobalAnsi.
Michael Taylor - 1/12/07
http://p3net.mvps.org