请教 关于dllinport 的问题

teal 2003-08-25 03:15:47
vc++ 写的dll中提供如下函数:
int f(wchar *a,wchar* b, wchar** c)

在C#下我江如何转换声明??
[DllImport("mydll.dll"), EntryPoint = "MessageBox", CharSet = Unicode)]

public static extern int my(??a, ??b,??int c);

帮忙了


...全文
56 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
panyee 2003-08-26
  • 打赏
  • 举报
回复
自己的dll和c#生成的.exe文件放在同一目录下
panyee 2003-08-26
  • 打赏
  • 举报
回复
public static extern long myproject (
[MarshalAs(UnmanagedType.LPWStr)] string useName,
[MarshalAs(UnmanagedType.LPWStr)] string password,
[MarshalAs(UnmanagedType.LPWStr)] string domainlist,
int size);
teal 2003-08-26
  • 打赏
  • 举报
回复
在 .h 文件中是这样定义的

extern HRESULT myproject(
LPWSTR useName,
LPWSTR password,
LPWSTR domainList,
Iint size
);

// 在C#中是这样的: 前面的几行
// project loginwin
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;


using System.Runtime.InteropServices;
namespace loginwin
{

/// <summary>
/// Summary description for Form1.
/// </summary>
public class creatmailbox : System.Windows.Forms.Form
{

[DllImport("myproject.dll")]
public static extern long myproject(string useName,string password,string domainList,int size);

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
……………………
……………………

请问这里那里有没有问题? myproject.dll 应该放在那个地方?
C#中 project loginwin的目录为 D:\\loginwin\
panyee 2003-08-25
  • 打赏
  • 举报
回复
string a, string b, string c

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧