http://blog.csdn.net/jingzhongrong/archive/2008/05/08/2416623.aspx
调用代码来自他这里.我在winform里测试成功了.但是在asp.net下不成功. int hModule = InvokeHelper.LoadLibrary(@"Express.dll");
if (0 != hModule)
{
}
else
{
return -1;
}代码就是上边这样.咋总返回-1?我把Express.dll放在bin下边了.想是这样才出错.所以改成
int hModule = InvokeHelper.LoadLibrary(@"D:\project\cha66\Site\Bin\Express.dll");但还是不能成功.我又放到system32了.还是不行.哪位有做过类似的?你们咋解决的啊?public static class InvokeHelper
{
[DllImport("Kernel32")]
public static extern int GetProcAddress(int handle, String funcName); [DllImport("Kernel32")]
public static extern int LoadLibrary(String fileName); [DllImport("Kernel32")]
public static extern int FreeLibrary(int handle); ///<summary>
///通过非托管函数名转换为对应的委托, by jingzhongrong
///</summary>
///<param name="dllModule">通过LoadLibrary获得的DLL句柄</param>
///<param name="functionName">非托管函数名</param>
///<param name="t">对应的委托类型</param>
///<returns>委托实例,可强制转换为适当的委托类型</returns>
public static Delegate GetFunctionAddress(int dllModule, string functionName, Type t)
{
int address = GetProcAddress(dllModule, functionName);
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
///<summary>
///将表示函数地址的IntPtr实例转换成对应的委托, by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(IntPtr address, Type t)
{
if (address == IntPtr.Zero)
return null;
else
return Marshal.GetDelegateForFunctionPointer(address, t);
}
///<summary>
///将表示函数地址的int转换成对应的委托,by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(int address, Type t)
{
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
//本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jingzhongrong/archive/2008/05/08/2416623.aspx
}
调用代码来自他这里.我在winform里测试成功了.但是在asp.net下不成功. int hModule = InvokeHelper.LoadLibrary(@"Express.dll");
if (0 != hModule)
{
}
else
{
return -1;
}代码就是上边这样.咋总返回-1?我把Express.dll放在bin下边了.想是这样才出错.所以改成
int hModule = InvokeHelper.LoadLibrary(@"D:\project\cha66\Site\Bin\Express.dll");但还是不能成功.我又放到system32了.还是不行.哪位有做过类似的?你们咋解决的啊?public static class InvokeHelper
{
[DllImport("Kernel32")]
public static extern int GetProcAddress(int handle, String funcName); [DllImport("Kernel32")]
public static extern int LoadLibrary(String fileName); [DllImport("Kernel32")]
public static extern int FreeLibrary(int handle); ///<summary>
///通过非托管函数名转换为对应的委托, by jingzhongrong
///</summary>
///<param name="dllModule">通过LoadLibrary获得的DLL句柄</param>
///<param name="functionName">非托管函数名</param>
///<param name="t">对应的委托类型</param>
///<returns>委托实例,可强制转换为适当的委托类型</returns>
public static Delegate GetFunctionAddress(int dllModule, string functionName, Type t)
{
int address = GetProcAddress(dllModule, functionName);
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
///<summary>
///将表示函数地址的IntPtr实例转换成对应的委托, by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(IntPtr address, Type t)
{
if (address == IntPtr.Zero)
return null;
else
return Marshal.GetDelegateForFunctionPointer(address, t);
}
///<summary>
///将表示函数地址的int转换成对应的委托,by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(int address, Type t)
{
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
//本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jingzhongrong/archive/2008/05/08/2416623.aspx
}
解决方案 »
- 请教有关三层模式的问题。
- Process 执行CMD有权限问题吗?
- 一个"2008-05-05"的字符串类型怎么转换成DateTime类型的?
- FireFox <a title="title过长有问题">123</a> 的问题 title内容过长给切断用...替换
- 保存文件
- 怎么获得客户端windows系统版本?
- 急:如何从一个DATAGRID将选中的信息导入另外一个DATAGRID
- AjaxControlToolkit工具包的一个控件问题(100分在线等)
- 高分求助,DataGrid编辑问题,急!
- 怎样更新数据源中的数据?
- ModalPopupExtender的postback问题,急急急急急急急,在线等
- 奇怪的问题:框架页面显示异常
右击bin文件夹—添加引用—浏览—选择要引用的dll文件—确定
DLL操作权限
<identity impersonate="true" userName="administrator" password="xxxxx" />