私はc#.netでネイティブAPIを呼び出そうとしています。以下のコードをC#呼び出しに変換するのを手伝ってもらえますか?本当にありがたいです。
dwResult = ::MprAdminMIBServerConnect( pwcComputerName.GetText(), &hMibServer );
dwResult = ::MprAdminServerGetInfo( hMibServer, 0, (LPBYTE*)&pServerBuf );
// I want to read the below variables as string
pInObjectEntry->Put(L"rastotalportstoconnectto", pServerBuf->dwTotalPorts );
pInObjectEntry->Put(L"rasportsinuse", pServerBuf->dwPortsInUse );
これがサンプルコードです。dwTotalPortsとdwPortsInUseの値を読み取る方法を教えてください。
class RASCollector
{
[DllImport("mprapi.dll", SetLastError = false)]
public static extern UInt32 MprAdminMIBServerConnect([MarshalAs(UnmanagedType.LPWStr)] string lpwsServerName, out IntPtr phMibServer);
[DllImport("mprapi.dll", SetLastError = false)]
public static extern UInt32 MprAdminServerGetInfo(IntPtr phMprServer, UInt32 dwLevel, out byte[] pServerBuf);
public void Run()
{
IntPtr hMibServer = new IntPtr();
UInt32 result;
result = MprAdminMIBServerConnect("localhost", out hMibServer);
byte[] pServerBuf;
result = MprAdminServerGetInfo(hMibServer, 0, out pServerBuf);
}
}