现在的位置: 首页 > 综合 > 正文

Windows XP style Explorer Bar使用问题说明

2013年06月11日 ⁄ 综合 ⁄ 共 1159字 ⁄ 字号 评论关闭

要想在vs2005中实现这样的效果,是没有相应的组件的,我使用的是codeproject

Mathew Hall上的Windows XP style Explorer Bar  将XPExplorerBar.dll添加到工具箱后,在使用时

但是会出现如下错误:

in visual studio 2005:
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'XPExplorerBar!XPExplorerBar.NativeMethods::LoadBitmap' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

the error is raised in the following line in GetResourceBMP method
IntPtr hBitmap = NativeMethods.LoadBitmap(hModule, Int32.Parse(resourceName));

 

这是由于winAPI中的long是32位,C#long是64位,生成可以成功,但是在执行后当然会出现堆栈不平衡的问题,在 vs2003中是捕获不出来的,但是在vs2005中是必须要处理的。

解决方法:

NativeMethods.cs中将

static extern IntPtr LoadBitmap(IntPtr hInstance, long resourceID)

中的long  换为int再重新生成即可。

我已经生成好.dll 文件并发布到我的资源里。

 

如有问题大家可以给我发邮件。

 

下载地址:

http://www.codeproject.com/cs/miscctrl/XPTaskBar.asp?select=1931404&df=100&forumid=55377#__comments

 

参考网站:

http://pinvoke.net/default.aspx/user32.LoadBitmap

.NET1.1升级到.NET2.0时出现的PInvokeStackImbalance错误

http://blog.csdn.net/virlene/archive/2006/05/29/761412.aspx

http://www.cnblogs.com/jillzhang/archive/2007/03/05/664657.aspx

 

抱歉!评论已关闭.