这样的函数怎么dllimport

deadshot123 2006-07-04 11:46:45
int WINAPI SysEnableCard( const char * configFile, const char * promptVoiceIdxFile )
...全文
229 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
deadshot123 2006-07-05
  • 打赏
  • 举报
回复
3Q CharSet=CharSet.Auto,
没有测试Ansi,Ansi和Nono都可以,Unicode不可以

参数用string StringBuilder托管都对的
deadshot123 2006-07-04
  • 打赏
  • 举报
回复
c++中使用SysEnableCard("","prompt.ini");调用正常

c#
public extern static int SysEnableCard([In, MarshalAs(UnmanagedType.LPTStr )] string configFile,[In, MarshalAs(UnmanagedType.LPTStr )] string promptVoiceIdxFile);

public extern static int SysEnableCard(StringBuilder configFile, StringBuilder promptVoiceIdxFile );

public extern static int SysEnableCard(ref StringBuilder configFile, ref StringBuilder promptVoiceIdxFile );

public extern static int SysEnableCard(ref string configFile, ref string promptVoiceIdxFile );

public extern static int SysEnableCard(string configFile, string promptVoiceIdxFile );
Knight94 2006-07-04
  • 打赏
  • 举报
回复
const char *:[In, MarshalAs(UnmanagedType.LPTStr )] string
Knight94 2006-07-04
  • 打赏
  • 举报
回复
还不行吗?

那就如下试试!
const char *:[In, MarshalAs(UnmanagedType.LPTStr )]
Knight94 2006-07-04
  • 打赏
  • 举报
回复
没有太大影响,const只是标明在函数内部不能被修改而已。
deadshot123 2006-07-04
  • 打赏
  • 举报
回复
跟用ref string 调用一样的结果

const有没有影响?
Knight94 2006-07-04
  • 打赏
  • 举报
回复
Have a try!
[DllImport(...)]
public extern static int SysEnableCard( StringBuilder configFile, StringBuilder promptVoiceIdxFile )
Knight94 2006-07-04
  • 打赏
  • 举报
回复
你在dllimport中是否加入了charset标示?

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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