【发布时间】:2012-06-03 15:51:03
【问题描述】:
正如 msdn http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx 所说,“平台调用服务 (PInvoke) 允许托管代码调用在 DLL 中实现的非托管函数。”
我想从我用 c++ 制作的 DLL 中导入一些类
有可能吗?如何实现?
例如,我在 DLL 中有一些结构:
struct __declspec(dllexport) DLLVector3
{
float x, y, z;
};
struct __declspec(dllexport) DLLQuaternion
{
float x, y, z, w;
};
class __declspec(dllexport) DLLCharacter
{
public:
DLLVector3 position;
DLLQuaternion orientation;
DLLCharacter()
{
}
~DLLCharacter()
{
}
void setPosition(PxVec3 pos)
{
position.x = pos.x;
position.y = pos.y;
position.z = pos.z;
}
void setOrientation(PxQuat or)
{
orientation.x = or.x;
orientation.y = or.y;
orientation.z = or.z;
orientation.w = or.w;
}
};
struct __declspec(dllexport) PhysicalObject
{
DLLCharacter *character;
PxRigidActor *mActor;
PxController *mController;
};
我可以通过什么方式导入这些?尤其是那些带有指针的结构
【问题讨论】:
-
为什么需要这个?您使用 .Net Questionerion 和 Vector3 并在 C# 中定义您的类
-
这只是类的一个例子...我有 DLL 与 PhysX 一起工作,加载网格,创建几何等,但我仍然需要从这个 DLL 导入一些类才能在 .用于追踪的网络。我不是制作 PhysX 包装器,而是更好地在 DLL 中实现所需的功能,并从我的 DLL 导入更少的东西,而不是整个 PhysX
标签: c# c++ class dll dllimport