C#调用API遇到类似PrivateExtractIcons这种输出参数应该如何做? PrivateExtractIconsA", CharSet = CharSet.Unicode指定了Ansi的函数,传参却用Unicode,自己跟自己过不去。把A换成W。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该只关系到第一个参数吧,我直接传字符串,不应该用PrivateExtractIconsA吗?我换成这样:public const int LR_DEFAULTCOLOR = 0x0; [DllImport("User32.dll", EntryPoint = "PrivateExtractIconsW", CharSet = CharSet.Auto)] public static extern int PrivateExtractIcons(string sFile, int nIconIndex, int cxIcon, int cyIcon, ref IntPtr phicon, ref IntPtr piconid, int nIcons, int flags); public static Image GetDLLIcon(string tFile, int nIconIndex, int iconSize) { Icon tmpImg=null; IntPtr tmp = IntPtr.Zero; IntPtr picon = IntPtr.Zero; PrivateExtractIcons(tFile, nIconIndex, iconSize, iconSize,ref tmp,ref picon, 0, LR_DEFAULTCOLOR); tmpImg=System.Drawing.Icon.FromHandle(tmp); return tmpImg.ToBitmap(); }调用System.Drawing.Image img = Win32API.GetDLLIcon("url.dll", 0, 16);或者System.Drawing.Image img = Win32API.GetDLLIcon(@"C:\Windows\System32\url.dll", 0, 16);一样不成功,请指点,谢谢! 自己疏忽,头昏了,参数传错了!picon, 1, LR_DEFAULTCOLOR同样讲解下A\W的事情吧,我传的是string呢,貌似必须使用W的才会成功,为什么 xml不能保存 和 文本不能写入 C#在桌面程序中怎么使用Server.URLEncode("汇编")函数? winform 中 引用.dll文件的问题 为什么CollectionBase实现了IList接口,却没有实现IList中的方法呢? 一个关于类型的问题(在线等) 帮忙写一个串口通信类(急!!!) 类似QQ"聊天记录" 如何处理??????? 当前不会命中断点。还没有为该文档加载任何符号 错误提示:排序字符串包含一个不在 IBindingList 中的属性。 一个关于在mysql数据表中如何查找前几条数据的问题 【【【为嘛这么坑爹?】】】 ActiveX与外界数据交互
[DllImport("User32.dll", EntryPoint = "PrivateExtractIconsW", CharSet = CharSet.Auto)]
public static extern int PrivateExtractIcons(string sFile, int nIconIndex, int cxIcon, int cyIcon, ref IntPtr phicon, ref IntPtr piconid, int nIcons, int flags); public static Image GetDLLIcon(string tFile, int nIconIndex, int iconSize)
{
Icon tmpImg=null;
IntPtr tmp = IntPtr.Zero;
IntPtr picon = IntPtr.Zero;
PrivateExtractIcons(tFile, nIconIndex, iconSize, iconSize,ref tmp,ref picon, 0, LR_DEFAULTCOLOR);
tmpImg=System.Drawing.Icon.FromHandle(tmp);
return tmpImg.ToBitmap();
}调用System.Drawing.Image img = Win32API.GetDLLIcon("url.dll", 0, 16);或者System.Drawing.Image img = Win32API.GetDLLIcon(@"C:\Windows\System32\url.dll", 0, 16);一样不成功,请指点,谢谢!