Using PInvoke with struct / Pointer instead of value

Hello,

currently I have to develop a Wrappper-DLL in C# for a given dll.
I begin to figure out how it works. But now I've no clue how to continue.
I have a struct like this in the header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
... 
 typedef int WV_CONNECT_ID ; 
 ... 
 typedef struct { 
    TCHAR             PatientName  [WV_PATIENT_NAME_SIZE] ; 
    TCHAR             PatientID    [WV_PATIENT_ID_SIZE] ; 
    TCHAR             BedLabel     [WV_BED_LABEL_SIZE]; 
    TCHAR             CareUnit     [WV_CARE_UNIT_SIZE]; 
    TCHAR             FileName     [WV_FILE_NAME_SIZE]; 
    TCHAR             IPAddress    [WV_IP_ADDRESS_SIZE]; 
    TCHAR             MulticastIP  [WV_MULTICAST_IP_SIZE]; 
    TCHAR             DeviceType   [WV_DEVICE_TYPE_SIZE]; 
    WV_OPERATING_MODE DeviceStatus ; 
    WV_CONNECT_ID     ConnectID ;  // 0 if not connected 
 } WV_BED_DESCRIPTION ;

WV_OPERATING_MODE is an enum

In the wrapper-DLL I use this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 
     public struct WV_BED_DESCRIPTION 
     { 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 26)] 
         public string PatientName; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string PatientID; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string BedLabel; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string CareUnit; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string FileName; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string IPAddress; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string MulticastIP; 
         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
         public string DeviceType; 
         public WV_OPERATING_MODE DeviceStatus; 
         public int ConnectID; 
     }

My problem is: for ConnectID I get a memory address (pointer) instead of the value and I have no idea why.
As far as I understand this it should be an value shouldn't it?

Thanks for any help in advance.

Wedgewood
Topic archived. No new replies allowed.