LoadLibrary失败(错误代码193)
问题描述:
我正在开发一个C应用程序来访问I2C端口我的评估套件。 taget详细信息如下
操作系统:Windows Compact 7
BSP:飞思卡尔的WINCE700 BSP。
BSP的参考手册建议应用程序可以使用dll I2cSDK.dll来执行I2C端口上所需的所有操作。但是当我尝试从我的应用程序加载这个
dll时,LoadLibrary函数返回NULL句柄,错误代码为193。
该应用程序的代码片段如下:
#include <stdio.h>
#include "stdafx.h"
#include "i2cbus.h"
#include <winioctl.h>
#include <windows.h>
#define I2C_ADAPTER_FREQUENCY 100000
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HINSTANCE handle;
DWORD error = NO_ERROR;
RETAILMSG(1, ( TEXT("LINE %d"), __LINE__ ) );
printf("Hello");
handle = LoadLibrary(TEXT("\\Windows\\i2csdk.dll") );
if(handle == NULL)
{
error = GetLastError();
RETAILMSG(1, ( TEXT("LoadLibrary FAIL error = %d"), error ) );
}
else
RETAILMSG(1, ( TEXT("handle to the library successfully created %d"), __LINE__ ) );
有没有人遇到这个问题?请有人指导我..
答
检查.bib文件中是否设置i2csdk.dll和'K'标志:你无法加载内核模式DLL在用户模式下。
Check the if i2csdk.dll kas the 'K' flag set in .bib files: you cannot load a kernel mode DLL in user mode.