C语言的代码
typedef struct
{
DJ_S8 m_s8ServerIp[32]; /*XMS server ip*/
DJ_U32 m_u32ServerPort; /*XMS server port*/
DJ_S8 m_s8UserName[32]; /**/
DJ_S8 m_s8UserPwd[32]; /**/
}ServerID_t;/**/
/**/
ServerID_t cfg_ServerID;
/*调用acsOpenStream 建立与ACS服务器的连接*/
r = XMS_acsOpenStream ( &g_acsHandle,
&cfg_ServerID,
g_u8UnitID, // App Unit ID
32, // sendQSize, in K Bytes
32, // recvQSize, in K Bytes
cfg_s32DebugOn, // Debug On/Off
NULL);
人家把C代码转成ActiveX控件
在NET中AcsOpenStream(ref int acsHandle, ref int serverID, short u8AppID, int u32SendQSize, int u32RecvQSize, int s32DebugOn, ref int privateData);ref int serverIDserverID应该对应的是ServerID_t类型,那为怎么会变成 (ref int serverID) INT哪?怎么解决啊。
解决方案 »
- C# 用程序 发邮件发到垃圾箱里了
- 关于C#的问题
- 如何知道类变量a由哪些本类的成员使用
- 在后台处理大量数据的时候,如何实现一个模态窗体,显示进度或者提示正在等待! 如果数据处理完毕,自动关闭该窗体
- 请问如何用CSC.EXE将CS文件编译成IL文件,注意,我要生成IL文件.
- WPF中如何保证一个控件的width和height始终相等?
- 请问C#如何取得某网页源代码并下载文件?
- 在C#中如何对剪切板进行操作?
- 请问DataReader + DataGrid 的分页问题?
- 使用System.Management写了一个远程关机(重启)的程序,发现对NT4无效,NT4下没有WMI吗?
- 菜鸟小妹提问线程不同步的问题!
- C# 简单的连接数据库
using System.Runtime.InteropServices;public struct Point
{
public int x;
public int y;
}class Example
{ static void Main()
{ // Create a point struct.
Point p;
p.x = 1;
p.y = 1; Console.WriteLine("The value of first point is " + p.x + " and " + p.y + "."); // Initialize unmanged memory to hold the struct.
IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p)); try
{ // Copy the struct to unmanaged memory.
Marshal.StructureToPtr(p, pnt, false); // Create another point.
Point anotherP; // Set this Point to the value of the
// Point in unmanaged memory.
anotherP = (Point)Marshal.PtrToStructure(pnt, typeof(Point)); Console.WriteLine("The value of new point is " + anotherP.x + " and " + anotherP.y + "."); }
finally
{
// Free the unmanaged memory.
Marshal.FreeHGlobal(pnt);
} }}
http://msdn2.microsoft.com/zh-cn/library/eadtsekz.aspx
http://msdn2.microsoft.com/zh-cn/library/3k3z0k7a.aspx
http://msdn2.microsoft.com/zh-cn/library/xedhyxyd.aspx
http://www.programfan.com/club/showpost.asp?id=16320
错误 1 不安全代码只会在使用 /unsafe 编译的情况下出现
我们公司只能访问 CSDN外网不开放。
unsafe
{
}
把不安全代码包含在内部。
typedef struct
{
DJ_S8 m_s8ServerIp[32]; /*XMS server ip*/
DJ_U32 m_u32ServerPort; /*XMS server port*/
DJ_S8 m_s8UserName[32]; /**/
DJ_S8 m_s8UserPwd[32]; /**/
}ServerID_t;/**/
/**/
ServerID_t cfg_ServerID; 推测DJ_S8是char类型,DJ_U32是unsigned int类型,在c#中定义:Struct XMLServerInfo
{
byte[32] ServerIp[32];
uint ServerPort;
byte[32] UserName[32];
byte[32] UserPwd[32];
}
XMLServerInfo myServerInfo = new XMLServerInfo();unsafe
{
AcsOpenStream(x,&myServerInfo...);
} 通过
string buffer;
buffer = System.Text.Encoding.Default.GetString(myServerInfo.ServerIp);
获得字符串信息。
http://download.csdn.net/user/lhsxsh
名称为“ActiveX控件在NET中的使用”
大家帮我测试下
AcsOpenStream(ref int acsHandle, ref int serverID, short u8AppID, int u32SendQSize, int u32RecvQSize, int s32DebugOn, ref int privateData);
方法中的 ref int serverID() 参数为ServerID_t的结构体C语言的代码
typedef struct
{
DJ_S8 m_s8ServerIp[32]; /*XMS server ip*/
DJ_U32 m_u32ServerPort; /*XMS server port*/
DJ_S8 m_s8UserName[32]; /**/
DJ_S8 m_s8UserPwd[32]; /**/
}ServerID_t;/**/
/**/
ServerID_t cfg_ServerID;
typedef unsigned char DJ_U8;
typedef char DJ_S8;
typedef unsigned short DJ_U16;
typedef short DJ_S16;
typedef unsigned int DJ_U32;
typedef int DJ_S32;
typedef unsigned long DJ_U32;
typedef long DJ_S32;
typedef unsigned long DJ_U40;
typedef long DJ_S40;
typedef double DJ_U64;
typedef double DJ_S64;
typedef unsigned long long DJ_U64;
typedef long long DJ_S64;
typedef bool BOOL;
对应到c#时我们要何类型,有些不是很确认如:long long 在NET是我们要怎么定义?
short 是不是对应NET的int16?
{
byte[32] ServerIp[32];
uint ServerPort;
byte[32] UserName[32];
byte[32] UserPwd[32];
}
这样的定义在C#中好像语法不对吧。
private struct ReceiveShutterInfo
{
public int[] receiveTime;
public int[] receiveCount;
public int[] reloadDspCardSeriesCount;
public bool isReceiveShutterStart;
public int receiveWaitCount; public ReceiveShutterInfo(int maxBufferNumber)
{
isReceiveShutterStart = false;
receiveWaitCount = 0;
receiveTime = new int[maxBufferNumber];
receiveCount = new int[maxBufferNumber];
reloadDspCardSeriesCount = new int[maxBufferNumber];
for (int i=0; i<maxBufferNumber; i++)
{
receiveTime[i] = GetTickCount();
receiveCount[i] = 0; // Edit 2006-03-02 11:35
reloadDspCardSeriesCount[i] = 0;
}
}
}private const int MAX_IPSTRING_LENGTH = 32;
private const int MAX_USERNAME_LENGTH = 32;
private const int MAX_PWD_LENGTH = 32;
private Struct XMLServerInfo
{
byte[] ServerIp;
uint ServerPort;
byte[] UserName[];
byte[] UserPwd[]; public XMLServerInfo()
{
ServerIp = new byte[MAX_IPSTRING_LENGTH];
UserName = new byte[MAX_USERNAME_LENGTH];
UserPwd = new byte[MAX_PWD_LENGTH];
}
}
名称为“ActiveX控件在NET中的使用”
大家帮我测试下
AcsOpenStream(ref int acsHandle, ref int serverID, short u8AppID, int u32SendQSize, int u32RecvQSize, int s32DebugOn, ref int privateData);
方法中的 ref int serverID() 参数为ServerID_t的结构体 为怎么会变成 ref int serverID INT? NET程序要怎么写?C语言的代码
typedef struct
{
DJ_S8 m_s8ServerIp[32]; /*XMS server ip*/
DJ_U32 m_u32ServerPort; /*XMS server port*/
DJ_S8 m_s8UserName[32]; /**/
DJ_S8 m_s8UserPwd[32]; /**/
}ServerID_t;/**/
/**/
ServerID_t cfg_ServerID;