Hi
For various reasons I need to access a C# class from within a VB project. The C# class calls an API.dll which returns fixed types which are not supported in VB.NET so the idea is to get the C# module to convert these before returning values to VB
So here's the problem - how do I get to access the C# clas in VB.NET the class is
public class API
{
// ¤Þ¥Î Fritz DLL
[DllImport("DllApCli.dll")
]
public static extern void DebugMsg(int bOn);
[DllImport("DllApCli.dll")
]
public static extern void ApOpen();
[DllImport("DllApCli.dll")
]
unsafe public static extern int ApConnectToServer(string szSrvIP, int dwSrvPort);
[DllImport("DllApCli.dll")
]
unsafe public static extern int ApGetVersion(out int iMajorVer, out int iMinorVer);
[DllImport("DllApCli.dll")
]
public static extern int ApMessageCount(int hAP);
[DllImport("DllApCli.dll")
]
public static extern void ApClose();
[DllImport("DllApCli.dll")
]
public static extern int ApEraseAllMessage(int hAP);
[DllImport("DllApCli.dll")
]
public static extern void ApDisconnect(int hAP);
[DllImport("DllApCli.dll")
]
unsafe public static extern int ApGetMessage(int hAP, out long dwUnitID, out int dwMsgID, byte* szBuff, int iBuffLen);
[DllImport("DllApCli.dll")
]
public static extern int ApAttachCount();
[DllImport("DllApCli.dll")
]
unsafe public static extern int ApSendCmd(int hAP, long dwUnitID, byte[] szCmd, int iCmdLen);
[DllImport("DllApCli.dll")
]
unsafe public static extern int GetNumberOfCleint();
}
An example of the ApSendCmd method as called in a C# project is shown below
public void SendMessage(string Message)
{
int IsOK;
byte[] Msg = Encoding.Default.GetBytes(
Message + "\r\n");
IsOK = API.ApSendCmd(m_hAP, System.Convert.ToInt32(tvO
BUGroup.Se
lectedNode
.Text), Msg, Msg.Length);
switch (IsOK)
{
case 0:
tbConsole.Text += "Send message failed." + "\r\n";
break;
default:
tbConsole.Text += "Send " + Message + " to " + tvOBUGroup.SelectedNode.Te
xt + "\r\n";
break;
}
}
How do I replicate this functionality in a VB.Net app?
Many thanks