<DllImport("gm7s32.dll")> _
Private Shared Function GMW_GetLicenseInfo(ByRef licenseInfo As GMW_LicInfo) As Integer
End Function
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Private Structure GMW_LicInfo
' msdn says a c CHAR is an 8 bit ansi character.
' we can marshal it as a string if we initialise it first.
' see topic "default marshaling for strings" in the library.
''' <summary>licensee name</summary>
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=60)> _
Public szLicensee As String
''' <summary>master serial number</summary>
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=20)> _
Public szLicNo As String
''' <summary>undocked site name</summary>
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=20)> _
Public szSiteName As String
' msdn says a c LONG is a 32-bit signed integer, so use int32
''' <summary>licensed users</summary>
Public iLicUsers As Integer
''' <summary>licensed SQL users</summary>
Public iSQLUsers As Integer
''' <summary>license GoldSync sites</summary>
Public iGSSites As Integer
'''<summary>is demo install</summary>
Public isDemo As Integer
'''<summary>is primary license ('D' or 'E')</summary>
Public isServerLic As Integer
''' <summary>is remote license ('U' or 'S')</summary>
Public isRemoteLic As Integer
''' <summary>is USA license (1=US,128/32bit, 0=nonUS, 32-bit only.</summary>
Public isUSALicense As Integer
''' <summary>the DLL version (400822)</summary>
Public iDLLVersion As Integer
Public iReserved1 As Integer
Public iReserved2 As Integer
' See topic 'Default marshaling for arrays' in the library
<MarshalAs(UnmanagedType.ByValArray, ArraySubType:=UnmanagedType.I4, SizeConst:=100)> _
Public szReserved() As Integer
Public Sub Initialize()
' fill the strings with dummy data
Me.szLicensee = New String("*"c, 60)
Me.szLicNo = New String("*"c, 20)
Me.szSiteName = New String("*"c, 20)
Me.szReserved = New Int32(99) {}
szReserved.Initialize()
End Sub
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim licInfo As New GMW_LicInfo
licInfo.Initialize()
' call
Dim result As Integer = GMW_GetLicenseInfo(licInfo)
' hopefully licinfo is now filled in...
End Sub