CreateFile打开物理磁盘失败,失败返回代码87,为什么呢? [问题点数:40分,结帖人erqerq126]

Bbs1
本版专家分:0
结帖率 100%
Bbs1
本版专家分:0
Bbs1
本版专家分:0
Bbs1
本版专家分:0
Windows核心编程-CreateFile详解
文件内核对象各种设备及其常见用途: 设备 常见用途 文件 永久存储任何数据 目录 属性和文件压缩的设置 逻辑磁盘驱动器 格式化驱动器 <em>物理磁盘</em>驱动器 访问分区表 串口 通过电话线传输数据 并口 将数据传输至打印机 邮件槽 一对多数据传输,通常是通过网络传到另一台运行Windows机器上 命名管道 一对一数据传输,通常是通过网络传到
CreateFile 函数详细解析
前言:    在Windows编程中CreateFile函数是用得非常多的,由于它的参数比较多比较复杂,在使用的时候容易出现问题,在学习了MSDN的官方文档后打算将其原文翻译出来,以供参考,如有错误,欢迎指正:lcb0281@163点comCreateFile     创建或<em>打开</em>文件或I/O设备。常用的I/O设备有:文件,文件流,目录,<em>物理磁盘</em>,卷,控制台缓冲区,磁带驱动器,通信资源,邮筒和管道。...
CreateFile返回创建文件失败
m_hFile = ::CreateFile((LPCTSTR)m_strFilePath, GENERIC_READ | GENERIC_WRITE ,rn FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);rn if(m_hFile == INVALID_HANDLE_VALUE)rn rn AfxMessageBox("创建文件<em>失败</em>");rn return -1;rn rn我单步走到这里的时候,老是近入if语句,不知道是怎么回事?rn我在m_strFilePath值为c:\\csl.txt,如果我把m_strFilePath值改为d:\\csl.txtrn单步调试就能够顺利跳过去,但是我在CreateFile设置了CREATE_ALWAYS,不管他存在不存在我都创建,怎么会<em>返回</em>INVALID_HANDLE_VALUE.~我想把已经存在c:\csl.txt覆盖一次<em>为什么</em>不行啊!~有什么办法吗>
createfile打开失败的问题??
#include rnrn#define _WIN32_WINNT 0x0500rn#include rnrnrnint main(int argc, char *argv[])rnrnrn HANDLE hDirectory = CreateFile("D:\\", GENERIC_ALL, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULLrn , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);rn rn if (INVALID_HANDLE_VALUE == hDirectory) [color=#FF0000] //现在是在这里出了鬼,老是无效句柄[/color]rn rn cout << "create file failed!" << endl;rn DWORD dwErr = GetLastError();rn return -1;rn rn rn while (TRUE)rn rn Sleep(1000);rnrn FILE_NOTIFY_INFORMATION stFileNotifyInfo = 0;rn DWORD dwBytesRet = 0;rnrn BOOL bRet = ReadDirectoryChangesW(rn hDirectory,rn &stFileNotifyInfo,rn sizeof (FILE_NOTIFY_INFORMATION),rn TRUE,rn FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE|FILE_NOTIFY_CHANGE_LAST_ACCESS|FILE_NOTIFY_CHANGE_CREATION|FILE_NOTIFY_CHANGE_SECURITY, rn &dwBytesRet,rn NULL,rn NULLrn );rn rn if (bRet)rn rn cout << "change occour!" << endl;rn rn rnrn CloseHandle(hDirectory);rnrn return 0;rnrnrn我想写个文件监控程序,我首先要用<em>createfile</em><em>打开</em>一个文件,得到handle,然后再ReadDirectoryChangesW,传递这个handle进去,但是我现在<em>createfile</em><em>打开</em>directory死活成功不了,错误号老是3,无法识别路径,出了鬼了,请各位帮忙看看,谢谢了.
CreateFile串口打开失败
static Handle hCom = NULL;rnhCom = CreateFile((LPCWSTR)"COM1", GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); rnif(INVALID_HANDLE_VALUE == hCom) rn rn INT err = GetLastError();//<em>为什么</em>每次都跑到这里来呢,err==2!!!!!!
请问createfile打开失败
我的操作如下:rnwchar_t fileName[256] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.txt";rnHANDLE hMedia = CreateFile(fileName, GENERIC_READ, rn FILE_SHARE_READ, NULL, OPEN_EXISTING, rn FILE_ATTRIBUTE_NORMAL, NULL);rnrnDWORD error = GetLastError();rnif (INVALID_HANDLE_VALUE == hMedia)rnrn printf("Open media file failed!\n");rnrnrn这样操作,怎么老是<em>失败</em>,请问怎么回事。谢谢。
c++ createFile()用法
CreateFile (1)函数原型 HANDLE CreateFile( LPCTSTR lpfileName, DWORD deDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes DWORD dwCreationDesposition, DWORD dwFlagsAndAt
CreateFile function
       创建或<em>打开</em>文件或I/O设备。最常用的I/O设备如下:文件、文件流、目录、<em>物理磁盘</em>、卷、控制台缓冲区、磁带驱动器、通信资源、邮件插槽和管道。函数<em>返回</em>一个句柄,可以根据文件或设备和指定的标志和属性来访问各种类型的I/O文件或设备。要将此操作作为事务处理操作执行,这将导致可用于事务处理I/O的句柄,使用CreateFileTransacted事务处理函数。HANDLE WINAPI Cre...
串口之CreateFile 函数详解
HANDLE CreateFile( LPCTSTR lpFileName, //指向文件名的指针 DWORD dwDesiredAccess, //访问模式(写/读) DWORD dwShareMode, //共享模式 LPSECURITY_ATTRIBUTES lpSecurityAttributes, //指向安全属性的指针 DWORD dwCreationDi
CreateFile() -- 打开与创建文件
CreateFile() 函数用以<em>打开</em>和创建文件,函数原型声明如下: HANDLE WINAPI CreateFile(   __in      LPCTSTR lpFileName,   __in      DWORD dwDesiredAccess,   __in      DWORD dwShareMode,   __in_opt  LPSECURITY_ATTRIBUTE
CreateFile打开USB设备失败
CString uDisk = "\\\\.\\PhysicalDrive";rnCString csNum = "1";//或"2","3",,,,rnHANDLE hDev = CreateFile(uDisk+csNum, GENERIC_WRITE|GENERIC_READ, rn FILE_SHARE_READ|FILE_SHARE_WRITE,rn NULL, OPEN_EXISTING,0,NULL);rnDWORD dwError = GetLastError();rnrn问题是:我在XR系统里以这样的方式<em>打开</em>U盘没有问题,但在Windows7里<em>打开</em>就出错,错误信息是dwError=ERROR_ACCESS_DENIED。我查过,可能是Windows账号权限不够的原因,请问各位大虾,有没有办法可以解决这个问题?谢谢!rnrn补充说明:我这里的U盘是自己做的,因为只有14Kbyte,所以做成FAT12格式的。
新手求教CreateFile()打开失败返回5
以前没有接触过windows的API,因为程序有用到,所以从网上复制了一个函数rnrn系统是win7,用工具激活为正版,VS2013社区版,程序启动方式为“右键-》已管理员身份运行”rnrn函数功能是判断某个盘符是否为U盘还是移动硬盘(需要把这两个和本地硬盘区别),其中有段<em>代码</em>用到了CreateFile(),问题也是出现在这里,出错,<em>返回</em>5rnrn[code=c]rn WCHAR newDrive[256]; //改函数传递进来的参数是CHAR* drive,这里转换为WCHARrn memset(newDrive, 0, sizeof(newDrive));rn MultiByteToWideChar(CP_ACP, 0, drive, strlen(drive)+1, newDrive, sizeof(newDrive)/sizeof(newDrive[0]));rn _wsetlocale(LC_ALL, newDrive);rn wprintf(L"%s", newDrive); //测试下转换是否正确,这里控制台显示结果"C:"而不是"C:/"rn //----rn hDevice = CreateFile(rn newDrive, // drive to openrn GENERIC_READ | GENERIC_WRITE, // access to the drivern FILE_SHARE_READ | FILE_SHARE_WRITE, //share modern NULL, // default security attributesrn OPEN_EXISTING, // dispositionrn 0, // file attributesrn NULL // do not copy file attributern );rn if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drivern rn fprintf(stderr, "CreateFile() Error: %ld\n", GetLastError()); //显示无法<em>打开</em>,错误5rn return DWORD(-1);rn [/code]rnrn我想问下<em>为什么</em>不能<em>打开</em>本地的C盘或者D盘或者E盘?
WINCE6,串口打开失败,CreateFile()返回-1
环境 VS2008,WINCE6,WINCE系统里有“COM1”,我用串口调试终端能<em>打开</em>”COM1“并且能发送与接收数据rn为了怕搞错串口名称,我干脆<em>打开</em>COM1-COM5,并且跟踪 m_hComm的值,发现<em>返回</em>的全部是 -1(0xffffffff), 这是我建的一个WINCE测试工程,就在下面这个函数里添加了如下<em>代码</em>,不知为何CreateFile()会<em>返回</em> -1,请高手指定一二,谢谢rnrnBOOL CWinceUartTestDlg::OnInitDialog()rnrn CDialog::OnInitDialog();rnrn // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动rn // 执行此操作rn SetIcon(m_hIcon, TRUE); // 设置大图标rn SetIcon(m_hIcon, FALSE); // 设置小图标rnrn // TODO: 在此添加额外的初始化<em>代码</em>rn HANDLE m_hComm=0;rn m_hComm =CreateFile(L"COM0", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm != -1)rn m_hComm =CreateFile(L"COM1", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm != -1)rn m_hComm =CreateFile(L"COM2", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm != -1)rn m_hComm =CreateFile(L"COM3", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm != -1)rn m_hComm =CreateFile(L"COM4", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm != -1)rn m_hComm =CreateFile(L"COM5", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);rn if((int)m_hComm == -1)rn MessageBox(L"COM0-COM5 Open Error!");rn elsern MessageBox(L"COM0-COM5 Open Succcess!");rnrn return TRUE; // 除非将焦点设置到控件,否则<em>返回</em> TRUErn
调用CreateFile失败为什么
我在远程登入了2003系统,并运行一个服务控制管理器的程序"Server.exe"。rn"Server.exe"中创建了一个主线程,主线程创建了一个邮槽服务:rnCreateMailslot("\\\\.\\mailslot\\my_mailslot", 0, MAILSLOT_WAIT_FOREVER, (LPSECURITY_ATTRIBUTES) NULL);rnrn然后主线程中又创建了1个应用程序进程"A.exe"rn在"A.exe"中调用CreateFile<em>打开</em>这个邮槽:rnCreateFile("\\\\*\\mailslot\\my_mailslot", GENERIC_WRITE, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); rn(1)这样调用的时候局域网和本地貌似都没错,但是如果我是在外网远程登入的时候,请问下这个第一个参数该填什么,底下那个servername该怎么填写,怎么得到。有没有什么API函数可以得到的。rn(2)my_mailslot这个填写绝对路径不行吗?我填写"D:\\Text\\my_mailslot"这样有错?rn(3)还有就是我在主线程结束前,调用PostThreadMessage(pProcInfo.dwThreadId, WM_QUIT, 0, 0)关闭"A.exe"的窗口时候会出现1444的错误报告,这个该怎么解决?rn(备注:pProcInfo.dwThreadId是前面创建"A.exe"进程的时候调用CreateProcessAsUser的最后一个参数)rnrn参考:rn 邮槽名字类型rn--------------------------------------------------------------------------------------------------------------------------rn名字格式 说 明rn--------------------------------------------------------------------------------------------------------------------------rn\\.\mailslot\name 标定同一台机器上的一个本地邮槽rn\\servername\mailslot\name 标定名为servername的一个远程邮槽服务器rn\\domainname\mailslot\name 标定在指定的domain(域)内,使用特定name(名字)的所有邮槽rn\\*\mailslot\name 标定系统主域内,标定特定name(名字)的所有邮槽rn--------------------------------------------------------------------------------------------------------------------------
::AfxInitRichEdit()返回失败,错误码:87
我用vs2012编写的客户端,发布后在虚拟机上测试,报::AfxInitRichEdit()<em>返回</em><em>失败</em>,错误码:<em>87</em>。在一般的机器上是没问题的。我把riched32.dll放在安装目录下,也不行。rn 请问那位高人指点一下!谢谢!
为什么createfile失败??
HANDLE hFileHandle = ::CreateFile(tcTempFileName,rn GENERIC_WRITE, FILE_SHARE_READ,rn NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);rnrn if (hFileHandle == INVALID_HANDLE_VALUE)rn rn CString str;rn int err = GetLastError(); rn str.Format("创建临时文件<em>失败</em>,%d",err);rn AfxMessageBox(str);rn rn给出的err是3:系统找不到指定的路径。 rnTCHAR tcTempFileName[MAX_PATH]=0;操作之后为 c:\a.datrn我路径都已经设置好了呀,为啥还会创建不成功呢?
为什么流接口驱动CreateFile失败呢?
HANDLE handle=CreateFile(_T("TTT1:"),GENERIC_READ|GENERIC_WRITE,0,rnNULL,OPEN_EXISTING,0,NULL);rnASSERT(handle);rnif (handle == INVALID_HANDLE_VALUE) // cannot open the drivernrn MessageBox(NULL,_T("CreateFile<em>失败</em>"),_T("title"),MB_OK);rnrn这<em>为什么</em>呢?
CreateFile打开USB端口失败
CreateFile函数<em>打开</em>USB端口<em>失败</em>,GetLastError <em>返回</em>错误为 32,表示端口被其它进程<em>打开</em>,但任务管理器没发现多余的软件rn同个软件在其它几台电脑上用是没问题的,CreateFile都是可以<em>打开</em>端口并收发数据,但有一台手提电脑上切总提示以上错误rn如果把CreateFile改为共享的方式<em>打开</em>端口是可以的,但是读写数据是不行的,rn请问这是什么原因呢,是系统的什么设置吗?rn谢谢
为什么我用CreateFile打开串口失败呢?
<em>为什么</em>用CreateFile<em>打开</em><em>失败</em>,<em>返回</em>值是~0rnCreateFile("com2", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, NULL, NULL);rn串口时虚拟的串口,rn但是open能<em>打开</em>也能传输数据rnopen("com2",O_RDWR)rn
打开串口失败 为什么呢?
VS08下编的win32程序 <em>打开</em>串口 <em>失败</em><em>为什么</em>呢?rn 建的是STANDARDSDK MIPSII平台设备的 程序放入设备中,设备串口和电脑PC机相连 rn 运行后,发现程序 <em>打开</em>串口<em>失败</em>?rn 有哪几种原因呢?驱动方面有问题?是不是驱动方面对串口的配置不对呢?还是怎么呢? 我不懂驱动rnvoid SendData(HDC hdc,LPCSTR buffer)rnrn HANDLE hcom;rn COMMCONFIG cc;rn DCB dcb;rn DWORD pt;rn RECT rect=20,20,60,60;rn hcom=CreateFile(L"COM1:",GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,NULL,NULL);rn if(hcom==INVALID_HANDLE_VALUE)rn rn DrawText(hdc,L"fail",5,&rect,DT_CENTER);rn return;rn rn GetCommState(hcom,&dcb);rn dcb.BaudRate=CBR_9600;rn dcb.fBinary=TRUE;rn dcb.fParity=FALSE;rn dcb.ByteSize=8;rn dcb.Parity=NOPARITY;rn dcb.StopBits=ONESTOPBIT;rn dcb.fRtsControl=RTS_CONTROL_ENABLE;rn dcb.fDtrControl=DTR_CONTROL_ENABLE;rn SetCommState(hcom,&cc.dcb);rn WriteFile(hcom,buffer,2,&pt,&ov);rnrnrn是不是也要在驱动中,把串口配置名为 COM1呢 (设备中共有两个串口)
为什么fopen打开失败呢?
bool Creat_Text(const char* str, const char* filename)nn char path[1024] = 0;n GetCurrentDirectory(1024, (LPWSTR)path);n strcat(path,"//");n strcat(path,filename);nn FILE* fp = fopen(path,"a+");n if (NULL == fp)n n return false;n nn fputs(str,fp);nn fclose(fp);n return true;n_
CreateFile失败 GetLastError()返回5 是什么原因
我这个工程是有一个主程序 然后调用很多的静态库 某一个静态库中有CreateFile()rnrncmd控制台的标签显示的是 管理员: C:\Window\system32\cmd.exernUAC执行文件也改成了 requireAdministratorrnrn但是CreateFile依然<em>失败</em> GetLastError()<em>返回</em>5rnrn编程小白 还有很多不懂的地方 还希望大家能谅解 也同时希望大神快来指导我一下 到底是什么原因
CreateFile()打开串口失败返回句柄值为0xffffffff
出错情况:设备1和设备2分别使用COM1和COM2外界通信,在不关闭软件的情况下,调换串口(即设备1/2,分别使用COM2/1),此时出错?以下是查找原因的步骤: _hCommHandle = ::CreateFile( _szCommStr, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLA
CreateFile创建文件失败??????????-〉help
新建一个Dialog程序rn在OnInitDialog()中添加rnrn HANDLE hFile;rn hFile = CreateFile("C:\tradex.txt",rn GENERIC_WRITE,rn FILE_SHARE_READ,rn NULL,rn CREATE_ALWAYS, rn FILE_ATTRIBUTE_NORMAL,rn NULL); rn if (hFile == INVALID_HANDLE_VALUE)rn rn MessageBox("Create file error!",NULL,MB_OK);rn return 0;rn rnrn编译没错,就是运行的时候出一框:Create file error!
CreateFile失败 GetLastError=2
[code=Delphi(Pascal)]rn#include rn#include rnrnvoid main()rnrn HANDLE handle=CreateFile("D:\\E.EXE", rn GENERIC_READ, rn FILE_SHARE_READ, rn NULL, rn OPEN_EXISTING, rn FILE_ATTRIBUTE_NORMAL, rn 0);rn if ( handle==INVALID_HANDLE_VALUE )rn rn printf( "%d",GetLastError() );rn return;rn rnrn[/code]
CreateFile创建串口失败
   HCom1ConnWithLcd = CreateFile(&quot;(LPCWSTR)COM1:&quot;,//COM1 GENERIC_READ|GENERIC_WRITE, //允许读和写 0, //独占方式 NULL, OPEN_EXISTING, //<em>打开</em>而不是创建 0, //同步方式 NULL);...
Windows 7下CreateFile()失败
我在Windows XP下调用如下<em>代码</em>没有问题,可在Windows 7下<em>失败</em>,GetLastError()<em>返回</em>2.rnrn清高手们帮忙解释一下啊.rnrn我用超级管理员的身份登陆Windows运行也是<em>失败</em>rnrnhDevice = CreateFile("\\\\.\\Ezusb-0",rn GENERIC_WRITE,rn FILE_SHARE_WRITE,rn NULL,rn OPEN_EXISTING,rn 0,rn 0);rnrn int error = GetLastError();rnrn if (hDevice == INVALID_HANDLE_VALUE) rn hDevice = CreateFile("\\\\.\\Ezusb-1",rn GENERIC_WRITE,rn FILE_SHARE_WRITE,rn NULL,rn OPEN_EXISTING,rn 0,rn 0);rnrn error = GetLastError();rnrn if (hDevice == INVALID_HANDLE_VALUE)rn return false;rn elsern return true;rn rn elsern return true;
CreateFile打开USB设备失败,GetLastError返回错误代码4
通过CreateFile<em>打开</em>一个指纹认证设备<em>失败</em>,错误<em>代码</em>为4.系统无法<em>打开</em>文件
关于CreateFile失败
Windows mobile 6 (vs2005)用CreateFile连续新建很多个文件,用模拟器来测试,共享pc机上的目录来模拟一个Storage Card目录rn hFile = CreateFile(lpFolder,rn GENERIC_READ|GENERIC_WRITE,rn FILE_SHARE_READ|FILE_SHARE_WRITE,rn NULL,rn CREATE_ALWAYS,rn FILE_ATTRIBUTE_NORMAL,rn NULLrn );rn如果我的lpFolder不是建在//Storage Card,就没问题。但如果是,CreateFile会在循环建立文件到某一次时<em>失败</em>,请问这是怎么回事?
CreateFile操作命名管道失败
服务器<em>代码</em>:rn[code=c]rn#include rn#include rnrnint main()rnrn HANDLE hpip;rn OVERLAPPED ovi = 0;rn char buff[200];rn DWORD readbuf;rn hpip = CreateNamedPipe( TEXT("\\\\.\\pipe\\pipename"), PIPE_ACCESS_DUPLEX,rn PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, NULL );rn printf( "success to create named pipe, waiting for client to connect. \r\n" );rn if( ::ConnectNamedPipe( hpip, &ovi ) )rn rn printf( "client success to connect!\r\n");rn printf( "reading data! \r\n" );rn if( ReadFile( hpip, buff, 200, &readbuf, NULL )) rn rn printf( "success to read data\r\n" );rn printf( "the data read is: %s\r\n", buff );rn rn elsern rn printf( "fail to read data!\r\n" );rn printf( "error message: %ld", GetLastError() );rn rn rn return 0;rnrnrn[/code]rnrn客户端<em>代码</em>:rnrn[code=c]rn#include rn#include rnrnint main()rnrn HANDLE hpip;rn OVERLAPPED ovi = 0;rn char buff[200] = "命名管道测试程序";rn DWORD readbuf;rn printf( "reading named pipe.\r\n" );rn rn if( WaitNamedPipe( TEXT("\\\\.\\pipe\\pipename"), NMPWAIT_WAIT_FOREVER))rn rn hpip = CreateFile( TEXT("\\\\.\\pipe\\pipename"), GENERIC_READ | GENERIC_WRITE , 0, rn NULL, OPEN_EXISTING, 0, NULL );rn if( hpip = INVALID_HANDLE_VALUE )rn rn printf( "fail to open named pipe\r\n" ); rn printf( "error message: %ld", GetLastError() );rn rn elsern rn if( WriteFile( hpip, buff, sizeof( buff ), &readbuf, NULL ) )rn rn printf( "success to write data.\r\n" ); rn rn elsern rn printf( "fail to write data.\r\n" ); rn rn rn rn elsern rn printf( "fail to connect named pipe. \r\n" );rn rn return 0;rnrnrn[/code]rnrn服务器端运行结果:rn-------------------------------------------rnsuccess to create named pipe, waiting for client to connect.rnclient success to connect!rnreading data!rnfail to read data!rnerror message: 109rn------------------------------------------rnrn客户端运行结果:rn----------------------------------------rnreading named pipe.rnfail to open named pipernerror message: 0rn----------------------------------------rnrnrn出错的位置是客户端程序的这一句:rn[code=c]rnrn hpip = CreateFile( TEXT("\\\\.\\pipe\\pipename"), GENERIC_READ | GENERIC_WRITE , 0, rn NULL, OPEN_EXISTING, 0, NULL );rn[/code]rnrn调试了很久也不行,请指教,谢谢。
createfile()创建文件失败的问题
我想以系统时间为名创建文件,下面是我的<em>代码</em>,有个问题一直过不去,运行环境是wince5.0,用VS2005开发;请明白人指教一下:[color=#FF0000]问题见批注[/color]rn 一,类Client中用到的相关<em>代码</em> rn public:rn int StartSave();rn private:rn static wchar_t save_date[60];rn static int save_callback( void *inst , void* sample);rn 二,StartSave()rn rn ...rn SYSTEMTIME saveNowtime;rn GetLocalTime(&saveNowtime); rn rn swprintf(save_date,(wchar_t*)(_T("\\\\硬盘\\\\%4d-%2d-%2d %2d:%2d:%2d.rec"))rn rn ,saveNowtime.wYear rn rn ,saveNowtime.wMonth rn rn ,saveNowtime.wDay rn rn ,saveNowtime.wHour rn rn ,saveNowtime.wMinute rn rn ,saveNowtime.wSecond); rn .....rnrn这一段的作用是将系统时间转化为一个字符串!rn 我用messagebox打印出save_date的值为\\硬盘\\2003-1-1 12:12:3.recrnrn三,在回调函数中创建文件rnrn hFile=CreateFile(save_date, rn GENERIC_READ|GENERIC_WRITE,rn 0,rn NULL,rn OPEN_ALWAYS,rn FILE_ATTRIBUTE_NORMAL,rn 0);rn if(hFile==INVALID_HANDLE_VALUE)rn rn MessageBox(NULL,_T("文件<em>打开</em><em>失败</em>"),0,0); rn return 0;rn rnrn 程序编译后无错误,在执行过程中总是打出”文件<em>打开</em><em>失败</em>“,我查看了错误<em>代码</em>是6号,也就是ERROR_INVALID_HANDLE,这是什么原因导致的啊?rnrn [color=#FF0000]注意:如果我在”hFile=CreateFile(save_date, “ rn 这一行前加wchar_t path[]=_T("\\硬盘\\book.txt");rn 并且把CreateFile的第一个参数换成path,则程序正常运行!所以感觉是save_date出问题了,但是打印出来路径对啊?不知跟宽字符有关吗?save_date和path都是宽字符啊?[/color]
CreateFile创建内存映射文件失败
system32\config\system,该文件无法拷贝,无法移动。rn现在我CreateFile文件<em>失败</em>,但我还想把这个文件映射到内存中去,该怎么操作?rn
请教调用CreateFile打开分区失败的原因。
我在vs2008中编译一个测试<em>代码</em>,<em>打开</em>一个分区,没有问题!rnrn测试通过后,我在vs2008里建立了一个QT工程,然后把测试<em>代码</em>嵌入里面,希望可以在图形界面中选择需要<em>打开</em>的分区,编译通过,但死活都是<em>打开</em>分区<em>失败</em>!rnrn<em>打开</em>分区的<em>代码</em>如下:rn_TCHAR volumePath[7];rn_sntprintf(volumePath, 6, _T("\\\\.\\%c:"), volume);rnvolumePath[6] = _T('\0');rnhVolume = CreateFile((LPCTSTR )volumePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,rn NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);rnrnrn查找<em>返回</em>的错误<em>代码</em>显示的错误是:rn刚开始的错误码是2:意思是找不到<em>打开</em>的文件rn换了好几个分区来<em>打开</em>时变成了这个错误:@err,hr 0x0000007b 文件名、目录名或卷标语法不正确。 unsigned longrnvolumePath的值显示是:\\.\\C:rn_TCHAR的大小是1rn不知道qt对这种反斜杠的文件名:\\.\\C: 有没有敏感,以致打不开分区。rnrn望知道错误的大侠指点
createfile()打开串口失败,求解答
hCom = CreateFile("COM1", //<em>打开</em>串口1rn GENERIC_READ | GENERIC_WRITE, //允许读和写操作rn 0, //独占方式rn NULL,rn OPEN_EXISTING, //<em>打开</em>一个存在的串口rn FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, //异步方式<em>打开</em>rn NULLrn );rnCreateFile()的<em>返回</em>值为INVALID_HANDLE_VALUE。rn用GetLastError()得到<em>返回</em>值为2,系统找不到指定路径。rnrn这个,要怎么改?rn谢谢大家。
用CreateFile打开物理磁盘,\\\\.\\PhysicalDrive0不行啊
下面的<em>代码</em>CreateFile<em>返回</em>错误值<em>87</em>,参数错误。rn如果我把PhysicalDrive0改成PhysicalDriver0,<em>返回</em>错误2,找不到设备。rn应该怎么改呢?rnrn[code=C/C++]rn#include "stdafx.h"rn#include rn#include rn#include rnint main() rn HANDLE hFile=CreateFile("\\\\.\\PhysicalDrive0",GENERIC_READ|GENERIC_WRITE,rn FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);rn if(INVALID_HANDLE_VALUE==hFile)rn printf("open error %d\n",GetLastError());rn rn return 0;rnrn[/code]
StgCreateDocfile失败,返回一个负数.为什么呢?
[code=C/C++]rn#includern#includern#pragma comment(lib,"ole32")rnint main(void)rn IStorage* pStg;rn HRESULT ret=StgCreateDocfile(L"e:\\myfile",STGM_CREATE,0,&pStg);rn printf("hr=%d\n",ret);rn return 0;rnrn[/code]rnrn输出hr=-2147286785rnrn这是<em>为什么</em>呢
hVXD=CreateFile失败
hVXD=CreateFile("\\\\.\\Inte.vxd",0,0,0,OPEN_EXISTING,FILE_FLAG_DELETE_ON_CLOSE,0);rn老是出现下面情况rnhVXD==INVALID_HANDLE_VALUErn前提有把Inte.vxd和Inte.inf拷贝到system32里面。rn请指教!rn
CreateFile打开串口失败(com10以上)
// get a handle to the port m_hComm = CreateFile(_T(&amp;quot;\\.\COM11&amp;quot;), // communication port string (COMX) GENERIC_READ | GENERIC_WRITE, // read/write types 0, // comm devices must be opened wit...
myconnection.Open();打开失败为什么
string ss="server=localhost;uid=sa;pwd=sa";rnSqlConnection myconnection=new SqlConnection(ss);rn tryrn rn myconnection.Open();rn Response.Write("Link successfully");rn rn catchrn rn Response.Write("Link failly");rn rn浏览的结果是:连接<em>失败</em>! 不解,我装了SQL Server 2000中文企业版,<em>为什么</em>连接<em>失败</em>????
为什么Server.CreateObject 失败呢?
我在页面中写rnrnrnProgIDMM.MmCtrl.1是我通过CLASSID7F148866-F98C-44EA-93A2-32B4BB9C1799在注册表中找到的rnrn访问后rnMicrosoft VBScript 编译器错误 错误 '800a03f6' rnrn缺少 'End' rnrn/iisHelp/common/500-100.asp,行242 rnrn服务器对象 错误 'ASP 0177 : 800401f3' rnrnServer.CreateObject <em>失败</em> rnrn/test/test.asp,行6 rnrn无效的 ProgID。 若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。rnrn这什么原因呢?rn这文件夹已经设置everyone 可以读写了rnrnrn
为什么连接数据库失败呢?
<em>代码</em>如下:rn public void Getconn()rn tryrnrn rn conn=DriverManager.getConnection("jdbc:sqlserver://bdcsbdcs/test","sa","");rn rn catch (SQLException e)rn System.out.print ("database conection failed");rn rnrn <em>为什么</em>出现database connction failed呢?rnrn 是不是要注册什么东东?rn 怎么注册呢?rn 我下载了jdbc for sql server得驱动程序rn 可是里面有很多类,rn 在 Class.forName()时用什么类名呢?rnrn
为什么调用失败呢?
前台:rn $.ajax(rn type: "POST",rn contentType: "application/json; charset=utf-8",rn url: "Default.aspx/PrintLabel",rn data: "'LOT':'123456789'", rn success: function (result) rn alert("o000");rn alert(result.d);rn ,rn error: function (a) alert("error") rn );rnrn后台:rn [WebMethod]rn public static string PrintLabel(string LOT)rn rn return LOT; rn rnrn结果第一个弹出框是对的,第二个一致是0,即使我后台写 return “aaaa”; 还是弹出0
为什么跟踪失败呢?
我设单步,当step out(shift+F11)就跳出个菜单上写Can't trace into system DLLs. rn请大侠指教,谢谢! rn我在学校的机子上没有上述提示,在自己机子上就有,是不是VC设置问题呢?? rnrn
为什么我的文件总是打开失败呢?
// ex1.7_2.cpp : 定义控制台应用程序的入口点。rn//rnrn#include "stdafx.h"rn#include rn#include rn#include rnrnusing namespace std;rnrnint _tmain(int argc, _TCHAR* argv[])rnrn cout<<<<>user_name;rn while(user_more)rn rn if (!game_datain) //到这里就完了,总是打不开我的D:\\game_datain.txt啊,<em>为什么</em>啊???????rn rn cout<>gamedata_name;rn if (gamedata_name == user_name)rn rn game_datain>>str_tries>>str_right;rn cout<<>user_tryAgain;rn rn elsern rn cout<<>user_tryAgain;rn rn while(user_tryAgain !='Y'&&user_tryAgain !='N'&&user_tryAgain !='y'&&user_tryAgain !='n')rn rn cout<>user_tryAgain;rn rn if(user_tryAgain == 'y'||user_tryAgain=='Y')rn rn user_more = true;rn rn elsern rn user_more = false;rn rn rn user_grade = double(user_right)/user_tries*100;rn /*if(!game_dataout)rn rn cout<<
createfile和copyfile都失败啊,为什么
[code=c]#include rn#include rn#define BUF_SIZE 256rnint main(int argc,LPTSTR argv[])rnrn /*HANDLE hIn,hOut;rn DWORD nIn,nOut;rn CHAR buff[BUF_SIZE];rn if (argc!=3)rn rn printf("参数错误\n");rn rn hIn = CreateFile(argv[1],GENERIC_READ,FILE_SHARE_READ,NULL,rn OPEN_EXISTING,NULL,NULL);rn if (hIn == INVALID_HANDLE_VALUE)rn rn printf("%s<em>打开</em><em>失败</em> error:%x\n",argv[1],GetLastError);rn rn hOut = CreateFile(argv[2],GENERIC_WRITE,FILE_SHARE_WRITE,NULL,rn CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);rn if (hOut == INVALID_HANDLE_VALUE)rn rn printf("创建<em>失败</em> error:%x\n",GetLastError);rn rn while (ReadFile(hIn,buff,BUF_SIZE,&nIn,NULL)&&nIn>0)rn rn WriteFile(hOut,buff,nIn,&nOut,NULL);rn if (nIn!=nOut)rn rn printf("文件读写错误:%x\n",GetLastError());rn return 4;rn rn rn CloseHandle(hIn);rn CloseHandle(hOut);rn */rn if (!CopyFile(argv[1],argv[2],FALSE))rn rn printf("复制出错 error:%x\n",GetLastError);rn return 2;rn rn return 0;rn[/code]rn刚开始学win系统编程,<em>代码</em>如上,就是简单的复制个文件rngetlasterror值是768a11c0
为什么CreateFile打开驱动第一次成功第二次失败
在ring3,利用CreateFile<em>打开</em>驱动rnm_hDevice = CreateFile (_T("\\\\.\\UHFControl"), 0, 0, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL);rn在ring0,创建设备rnrn status = IoCreateDevice (DriverObject,rn sizeof (CControlDeviceExtension*),rn &m_NameString, // No Namern m_DriverType,rn FILE_DEVICE_SECURE_OPEN,rn FALSE,rn &m_Self);rn这是一个usb hub过滤驱动,进行USB设备的重定向,结果对第一个设备进行重定向可以成功,第二个就偶尔会<em>失败</em>。通过getlasterror获得的错误<em>代码</em>是2,系统找不到指定的文件rn求指点,<em>为什么</em>啊?
【求助】为什么我用CreateFile打开串口总是失败
在 WIN2K + VB6 下用 CreateFile <em>打开</em>串口总是, 总是<em>返回</em> -1rnrn Dim lret As Longrn lret = CreateFile("COM3", GENERIC_READ Or GENERIC_WRITE, _rn 0&, 0&, OPEN_EXISTING, 0&, 0&)rnrnrn If lr = INVALID_HANDLE_VALUE Thenrn MsgBox GetAPIError, vbExclamation, "<em>打开</em>串口出现错误:"rn Init_COMM = 0rn Exit Functionrn End Ifrnrn然后 用 FormatMessage <em>返回</em> 错误描述是: 操作已完成 ,可是<em>返回</em>的 lret = -1 啊, 同时在 超级终端上读取<em>打开</em>,关闭,通讯一切正常。rnrnCOM3 是我用 USB 虚拟出的串口设备。
CreateFile 串口打不开,如下代码.....提示 打开COM失败
CreateFile 串口打不开,如下<em>代码</em>.....rn hCom=CreateFile("COM15", // 文件名rn GENERIC_READ | GENERIC_WRITE, // 允许读和写 rn 0, // 独占方式rn NULL, rn OPEN_EXISTING, //<em>打开</em>而不是创建rn FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, // 重叠方式rn NULLrn );rn rn rn if(hCom==INVALID_HANDLE_VALUE)rn rn AfxMessageBox("<em>打开</em>COM<em>失败</em>!");rn int err=GetLastError(); rn CString st;rn st.Format( "Error in open COM port: %d\n", err ); rn MessageBox(st); rn return;rn
vc 直接写物理磁盘,writefile 失败 错误返回5 拒绝访问
如题,求解决问题,<em>createfile</em>("\\\\.\\PhysicalDrive2", GENERIC_READ | GENERIC_WRITE,rn FILE_SHARE_READ | FILE_SHARE_WRITE,rn NULL,rn OPEN_EXISTING,rn 0,rn NULL);
sendto为什么总是返回失败
[color=#FF00FF]劳烦各位大大,看一下下面的程序,sendto<em>为什么</em>总是<em>返回</em><em>失败</em>[/color]rn[code=C/C++]rn#include rn#include rn#pragma comment (lib,"ws2_32.lib")rnrnDWORD WINAPI RecvDataThread(LPVOID lpParameter);rnDWORD WINAPI SendDataThread(LPVOID lpParameter);rnHANDLE hThread1;rnHANDLE hThread2;rnrnSOCKET g_sConnect;rnSOCKADDR_IN g_aLocal;rnSOCKADDR_IN g_aRemote;rnCRITICAL_SECTION g_cs;rnint len = sizeof(SOCKADDR);rnrnBOOL InitSocket()rnrn WORD wVersionRequested=MAKEWORD(2,2);rn WSADATA wsaData;rnrn if( WSAStartup(wVersionRequested, &wsaData) != 0)rn rn return FALSE ;rn rnrn if( LOBYTE( wsaData.wVersion) != 2 || HIBYTE( wsaData.wVersion) !=2 )rn rn WSACleanup();rn return FALSE;rn rnrn SOCKET g_sConnect = socket(AF_INET,SOCK_DGRAM, 0 );rnrn g_aLocal.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");rn g_aLocal.sin_family = AF_INET;rn g_aLocal.sin_port = htons(6100);rnrn g_aRemote.sin_addr.S_un.S_addr = inet_addr("202.38.64.111");rn g_aRemote.sin_family = AF_INET;rn g_aRemote.sin_port = htons(6101);rnrn bind(g_sConnect,(struct sockaddr*)&g_aLocal,sizeof(g_aLocal)); rnrn return TRUE;rnrnrnint main(int argc, char* argv[])rnrn if (InitSocket())rn rn InitializeCriticalSection(&g_cs);rn printf("套接字初始化成功!\n\n");rn hThread1=CreateThread(NULL,0,SendDataThread,NULL,0,NULL);rn hThread2=CreateThread(NULL,0,RecvDataThread,NULL,0,NULL); rn CloseHandle(hThread1);rn CloseHandle(hThread2);rn rn elsern rn printf("套接字初始化<em>失败</em>!\n");rn return 1;rn rnrn while(1)rn rn rnrn closesocket(g_sConnect);rn WSACleanup();rn DeleteCriticalSection(&g_cs);rnrn return 0;rnrnrnDWORD WINAPI SendDataThread(LPVOID lpParameter)rn rn while(1)rn rn char sendBuf[1000]="";rnrn EnterCriticalSection(&g_cs);rn Sleep(1000);rnrn printf("Please input data:\n");rn gets(sendBuf);rnrn if(sendto(g_sConnect,sendBuf, strlen(sendBuf )+1, 0 ,(SOCKADDR*)&g_aRemote, len)!=SOCKET_ERROR)rn rn printf("sendto success!\n");rn rn elsern rn printf("sendto failure!\n");rn rnrn LeaveCriticalSection(&g_cs);rn rnrn return 0;rnrnrnDWORD WINAPI RecvDataThread(LPVOID lpParameter)rn rn while(1)rn rn char recvBuf[1000]="";rn char tempBuf[1000]="";rnrn EnterCriticalSection(&g_cs);rn Sleep(1000);rnrn if( recvfrom(g_sConnect, recvBuf, 1000, 0, (SOCKADDR*)&g_aRemote,&len)!=SOCKET_ERROR)rn rn sprintf(tempBuf, "%s say:\n%s", inet_ntoa(g_aLocal.sin_addr), recvBuf);rn printf("%s\n", tempBuf);rn rn elsern rn printf("recvfrom failure!\n");rn rn rn LeaveCriticalSection(&g_cs);rn rnrn return 0;rnrn[/code]
为什么SSL_accept总是返回失败?
我的程序在一台机器上SSL_accept总是<em>返回</em><em>失败</em>,但在另外一台机器上则一切正常,这是怎么回事?rnERR_error_string<em>返回</em>的是:rnerror:140B544E:SSL routines:SSL_GET_NEW_SESSION:ssl session id callback failed
为什么SSL_accept总是返回失败
我的程序在一台机器上SSL_accept总是<em>返回</em><em>失败</em>,但在另外一台机器上则一切正常,这是怎么回事?rnERR_error_string<em>返回</em>的是:rnerror:140B544E:SSL routines:SSL_GET_NEW_SESSION:ssl session id callback failed
CreateFile调用总是失败,怎么回事?
CreateFile这个函数<em>打开</em>文件的时候总是<em>失败</em>,大家帮忙分析一个,这是什么原因呢?rn[code=C/C++]#includern#includern#includern#includernrnHANDLE hFile;rnHANDLE hFileMapping=NULL;rnvoid *pFileBase=NULL;rnrnint main(int argc,char **argv)rn rn if(argc!=2)rn rn printf("Usage:\n\t %s PE File\n",argv[0]);rn exit(1);rn rn rn /*********************** Map the file to memory *************************/rn hFile=CreateFile(argv[1],GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,rn FILE_ATTRIBUTE_ARCHIVE,OPEN_EXISTING,NULL);rn if(hFile==INVALID_HANDLE_VALUE)rn rn /*printf("Open File Error.\n");*/rn printf("Open File Error\n");rn exit(2);rn rn rn hFileMapping=CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL);rn if(!hFileMapping)rn rn CloseHandle(hFile);rn perror("Create File Mapping Error\n");rn exit(3);rn rn pFileBase=MapViewOfFile(hFileMapping,FILE_MAP_READ,0,0,0);rn if(!pFileBase)rn rn CloseHandle(hFileMapping);rn CloseHandle(hFile);rn perror("Map View of File Error.\n");rn exit(4);rn rn /*********************** Map end *****************************************/rn rn rn return EXIT_SUCCESS;rnrn[/code]
USB CreateFile 失败 GetLastError() = 2
for循环到第4次时CreateFile就<em>失败</em>了,GetLastError值为2,这是什么原因啊,怎么解决。rnrnBOOL HY_Get_USBDevice(void)rnrn CHAR HCName[32];rn int HCNum;rn HANDLE hHCDev;rnrn for (HCNum = 0; HCNum < 10; HCNum++)rn rn sprintf(HCName, "\\\\.\\HCD%d", HCNum);rn hHCDev = CreateFile(HCName,rn GENERIC_WRITE,rn FILE_SHARE_WRITE,rn NULL,rn OPEN_EXISTING,rn 0,rn NULL);rn if (hHCDev == INVALID_HANDLE_VALUE)rn {rn int rst = GetLastError();rn break;rn }rn rn ......rn
使用createfile总是失败,请教
使用CreateFil("C:\tt.txt",GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);总是<em>失败</em>,向各位请教
CreateFile失败的问题。请帮忙。
serverHandle = CreateFile( pipeName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | E_FLAG_WRITE_THROUGH, NULL);rnrnif(serverHandle != INVALID_HANDLE_VALUE)rn break;rnrn程序有时正常运行。但是,又是在if语句之前就出错了。不知道是何原因。
win32串口编程中CreateFile失败
我想在win32下实现串口编程,下了一个例子照着打进去后怎么都创建<em>失败</em>。。。。各位兄弟姐妹们帮帮忙吧,谢谢各位了先rnHANDLE hCom=CreateFile((LPWSTR)("COM1:"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,rnFILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,NULL);rnif(hCom==(HANDLE)-1)rnrnreturn false;rnrn怎么每次都<em>失败</em>呢。。。。我就纳了个闷了。。。rn我已经用虚拟串口工具虚拟了COM1和COM2端口的连接rn也用串口调试工具测试了下,显示这两个端口都空闲,可就是连不上啊。。。。rn[img=http://hi.csdn.net/space-3555420-do-album-picid-653506.html][/img]rn[img=http://hi.csdn.net/space-3555420-do-album-picid-653505.html][/img]
为什么我的项目打开失败????
程序运行过程中死机了,只好重启。重启后加载项目时<em>失败</em>,项目文件没有<em>打开</em>,这是怎么回事。是不是项目文件损坏了,我该如何修复呢,总不至于让我重新写吧。55555555555
cvCreateFileCapture为什么总是打开失败
cap = cvCreateFileCapture(zStr);rn if (cap==NULL)rn rn MessageBox(_T("cap"));rn return ;rn rnrn在我自己的电脑上cap 不为空;在其他电脑上总是为空 rnrn求如何解决
为什么安装VC6.0失败
我的电脑是win2000专业版本,加SP4补丁,加OFFICE2000rn<em>为什么</em>安装VC6.0与VB6.0时,总到最后文件复制完毕后,提示安装<em>失败</em>,详细查看www.microsoft.com/msdn
装载图片失败----为什么呢?
rnrnrn BITMAP bm;rn HBITMAP hBitmap;rn HDC hSrcDC; rnrnrnhSrcDC = CreateCompatibleDC(m_memodc->m_hDC );rn hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),temp,IMAGE_BITMAP,0,0,LR_LOADFROMFILE |LR_SHARED);//|LR_CREATEDIBSECTION);rn rn sint=GetObject(hBitmap, sizeof BITMAP, &bm);rn SelectObject(hSrcDC, hBitmap);rn rn GetClientRect(&rect);rn ::SetStretchBltMode(m_memodc->m_hDC ,COLORONCOLOR); rn ::StretchBlt(m_memodc->m_hDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);rnrnrn///以上<em>代码</em>运行一段时间后就出现图片文件装载<em>失败</em>rn///<em>代码</em>本身是每隔10多秒就装载一幅图,然后再在memode上做图,再显示出来,rn///可是到后面就显示不出来做为背景的图片了?rn///求救高手,谢谢rn
loadXML总是失败为什么呢?
环境是 vs2008,一个从vc6.0升级上来的工程。rn在使用loadXML的是,总是无法成功。rn测试用的xml文档可以ie里头正确显示。rnCoUninitialize();rn是已经调用了的。rnrnbool HtmlItf::IsSuccess(BSTR sXML)rnrnrnIXMLDOMDocument *pXmlDoc=NULL; rnrnHRESULT hr=CoCreateInstance(CLSID_DOMDocument,NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER/*CLSCTX_ALL*/, IID_IXMLDOMDocument,(LPVOID*)&pXmlDoc); rnrnif(hr == S_OK)rnrnVARIANT_BOOL bFlag=VARIANT_FALSE;rnpXmlDoc->put_async(VARIANT_FALSE);rnpXmlDoc->put_validateOnParse(VARIANT_TRUE);rnhr = pXmlDoc->loadXML(sXML,&bFlag); ///get_documentElement(&pNodeElement);rnrnif(hr != S_OK)return false;rnrnIXMLDOMNodeList *pNodeList;rnrnhr = pNodeElement->get_childNodes(&pNodeList);rnrnif(hr == S_OK)rnrnIXMLDOMNode *pStateNode;rnBSTR s;rnBSTR sNodeName;rnlong NodeLen;rnpNodeList->get_length(&NodeLen);rnfor(int i=0;iget_item(i,&pStateNode);rnpStateNode->get_nodeName(&sNodeName);rnpStateNode->get_text(&s);rnif(sNodeName = BSTR("state"))rnrnif(s==BSTR("0"))rnreturn false;rnelse if(s==BSTR("1"))rnreturn true;rnrnrnrnrnrnreturn false;rn
为什么创建文件总是失败呢?
rn普通用户, 用open函数创建文件(不存在该文件)rnfd = open( path, O_CREAT | O_RDWR, S_IRUSE | S_IWUSR );rnrn<em>为什么</em>这样创建文件总是<em>失败</em>呢?如果时超级用户就没有这个问题。
为什么调用API失败呢?
我的系统是WIN XP,程序中用了下面的API,然后程序运行时报错:说找不到RegisterServiceProcess函数的入口。rnrn请问,该怎样解决?rnrnrnrnrnrnrnrnrnPrivate Declare Function GetCurrentProcessId Lib "kernel32" () As LongrnrnPrivate Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As LongrnrnPrivate Const RSP_SIMPLE_SERVICE = 1rnPrivate Const RSP_UNREGISTER_SERVICE = 0rnrnPrivate Sub Form_Load()rnrn Call RegisterServiceProcess(GetCurrentProcessId, 1)rnrnEnd Subrn
DeviceIoControl时,总是返回失败,错误码是87(参数错误)
直接上<em>代码</em>,各位看看,调用时总是<em>失败</em>,调用GetLastError时错误码是<em>87</em>(参数错误)rnrn//---------------------------------------定义rn BULK_TRANSFER_CONTROL=recordrn pipeNum:Cardinal;//对应ULONGrn end;rnm_Usb_Handle:THandle;//已经成功<em>打开</em>rn//功能码是对的rnfunction IOCTL_EZUSB_BULK_WRITE:DWORD; rnbeginrn result:=CTL_CODE(FILE_DEVICE_UNKNOWN,Ezusb_IOCTL_INDEX+20,METHOD_IN_DIRECT,FILE_ANY_ACCESS);rnend;rnrn dataBuffer:Array[0..32] of Char;rn dataBufferSize,lpBytesReturned:DWORD;rn outBulkControl:BULK_TRANSFER_CONTROL;rn outPBulkControl:Pointer;rnrn//--------------------------------调用<em>代码</em>rn //要下发16个字节的 1rn dataBufferSize:=16;rn for i:=0 to dataBufferSize-1 dorn beginrn dataBuffer[i]:=#1;rn //dataBuffer[2*i]:='1';rn //dataBuffer[2*i+1]:='1';rn //dataBuffer[2*i+2]:=#0;rn end;rnrn outBulkControl.pipeNum:=2; //输出端点 0 Endpoint: 2 OUTrn outPBulkControl:=@outBulkControl;rn if (m_Usb_Handle<>Windows.INVALID_HANDLE_VALUE) thenrn beginrn lpBytesReturned:=0;rn if DeviceIoControl(m_Usb_Handle,IOCTL_EZUSB_BULK_WRITE,outPBulkControl,SizeOf(BULK_TRANSFER_CONTROL),rn @dataBuffer,dataBufferSize,lpBytesReturned,nil) thenrn beginrn //发送成功rn Memo1.Lines.Add(Format('发送数据成功 Result=%d',[lpBytesReturned]));rn endrn else beginrn iErrorCode:=windows.GetLastError;rn Memo1.Lines.Add(Format('发送数据<em>失败</em> ErrorCode=%d(%s) Result=%d OutBufferSize=%d',[iErrorCode,getErrorTextByCode(iErrorCode),lpBytesReturned,dataBufferSize]));rn // GetLastError =<em>87</em> 〖<em>87</em>〗-参数错误。rn end;rnrn//执行后输出的结果是:rnrn<em>打开</em>USB成功rn发送数据<em>失败</em> ErrorCode=<em>87</em>(参数错误) Result=0 OutBufferSize=16rnData->> 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01rn关闭USB成功rnrnrn***** IOCTL_Ezusb_GET_PIPE_INFO ****** rn获得端口点列表数据成功 Result=56rnPipe Endpoint Direction Type Sizern 0 2 IN BLK 16rn 1 6 OUT BLK 512rnrnrnrn[b]请大家帮我看看,谢谢,分数我尽量多点,我的分也不多[/b]
DeviceIoControl失败,GetLastError()返回87,求高手解答!!!
[code=C/C++]DWORD dwNum, dwOut = 4, dwOutRet;rn HANDLE hDriver = CreateFile(".//EnumProcess.sys",rn GENERIC_READ | GENERIC_WRITE,rn 0, rn NULL, rn OPEN_EXISTING,rn FILE_ATTRIBUTE_NORMAL,rn NULL);rn if(INVALID_HANDLE_VALUE == hDriver)rn rn MessageBox("CreateFile failed!");rn return FALSE;rn rn //获取进程个数rn BOOL bOk = DeviceIoControl(hDriver,rn IOCTL_NUM,rn NULL, 0,rn &dwNum,rn dwOut,rn &dwOutRet,rn NULL);rnrn[/code]rnbOk一直为FALSE, GetLastError()<em>返回</em><em>87</em>,一直弄不明白,请高人指教小弟!
regcreatekeyex 调用失败返回87 错误码是0
附上<em>代码</em>。。rn Privilege(); //这是提权函数。。能正确执行。rnHKEY hkey; rnconst char *subkey=_T("Software//Microsoft//Windows NT//CurrentVersion//Winlogon//Notify//crypt");rn DWORD dwDisposition;rn int a=RegCreateKeyEx(HKEY_LOCAL_MACHINE,rn subkey,rn 0,rn REG_NONE,rn REG_OPTION_NON_VOLATILE,rn KEY_WRITE|KEY_READ,rn NULL,rn &hkey,rn &dwDisposition);rn太蛋疼了,,写如注册表,regcreatekeyex调用<em>失败</em>,<em>返回</em>值<em>87</em>,getlasterror()的到错误码是0,FormatMessage翻译后错误信息是“操作成功完成”。。。在XP下运行的。。各种方法都试过了,google,百度,看遍了,,真没找到原因。。知道原因的告诉下谢谢了。。
为什么WaitCommEvent()返回err=87
我创建时用的属性是FILE_FLAG_OVERLAPPED,并且SetCommMask (hCom, EV_RXCHAR),rnread_overlapped.hEvent = CreateEvent (NULL, TRUE, FALSE, "read");rnrn在监听串口时,用WaitCommEvent (hCom, &event_mask, &read_overlapped);rn但是,总<em>返回</em>GetLastError() = <em>87</em>,即The parameter is incorrect,可是我看不出有什么错误。rnrn各位高手有什么见解?
为什么regsavekey总是返回87
程序如下,请看看哪里出错?rnrnPrivate Sub Command1_Click()rn If SaveKey(HKEY_CLASSES_ROOT, "ServoWorks\S100M", "s100m.txt") = True Thenrn MsgBox "save!"rn End IfrnrnEnd SubrnrnrnPublic Function SaveKey(KeyRoot As KeyRoot, KeyName As String, FileName As String) As Booleanrn On Error Resume Nextrn rn Dim lpAttr As SECURITY_ATTRIBUTES ' 注册表安全类型rn lpAttr.nLength = 50 ' 设置安全属性为缺省值...rn lpAttr.lpSecurityDescriptor = 1 ' ...rn lpAttr.bInheritHandle = True ' ...rn rn If EnablePrivilege(SE_BACKUP_NAME) = False Thenrn SaveKey = Falsern Exit Functionrn End Ifrn rn Success = RegOpenKeyEx(KeyRoot, KeyName, 0&, KEY_ALL_ACCESS, hKey)rn If Success <> 0 Thenrn SaveKey = Falsern Success = RegCloseKey(hKey)rn Exit Functionrn End Ifrn rn [color=#FF0000]Success = RegSaveKey(hKey, FileName, lpAttr)[/color]rn If Success = 0 Then SaveKey = True Else SaveKey = Falsern rn Success = RegCloseKey(hKey)rnEnd Functionrnrn每次都是红色字体处 <em>返回</em><em>87</em>(参数错误),但是错在哪里?rn
dll加载失败,GetLastError返回值是87,是什么原因呢?
dll加载<em>失败</em>,GetLastError<em>返回</em>值是<em>87</em>,是什么原因呢?
MapViewOfFile失败,错误码为5,8,或87
[align=left] BITMAPINFO bmi;rn ::ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));rn DWORD biSizeImage = iWidth*iHeight*64;rn bmi.bmiHeader.biWidth = iWidth;rn bmi.bmiHeader.biHeight = -(iHeight); //negative indicate top down, not bottom uprn bmi.bmiHeader.biPlanes = 1;rn bmi.bmiHeader.biBitCount = 32;rn bmi.bmiHeader.biSizeImage = biSizeImage; rn bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);rn bmi.bmiHeader.biClrUsed = 0;rn bmi.bmiHeader.biClrImportant = 0;rn bmi.bmiHeader.biCompression = BI_RGB;rn VOID *pvBits;rn TCHAR szName[]=TEXT("MyFileMappingObject");rnrn DWORD biBufferSize = biSizeImage + iWidth*64;rn rn rn HANDLE _hFile = CreateFile("test.bmp", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);rn if(!_hFile)rn return NULL;rn rn HANDLE hMap=CreateFileMapping(_hFile, NULL, PAGE_READWRITE|SEC_COMMIT, 0, biBufferSize,szName);rn if (hMap != NULL) rn rn // We might have a winnerrn if (GetLastError() == ERROR_ALREADY_EXISTS) rn CloseHandle(hMap); rn else rn rn rnrn //HANDLE hMap=CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, biBufferSize,szName);rn rn if(_hFile)rn rn CloseHandle(_hFile);rn _hFile = NULL;rn rn rn LPVOID pBuffer = MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, biSizeImage); rn if(pBuffer == NULL)rn rn DWORD ErrNo = GetLastError();rn rn rn rn HBITMAP hBitmap = ::CreateDIBSection(iHDC, &bmi, DIB_RGB_COLORS, &pvBits, hMap, 0);rnrn if(hBitmap == NULL)rn rn DWORD ErrNo = GetLastError();rn rnrn UnmapViewOfFile(pBuffer);rn CloseHandle(hMap);rn if(_hFile)rn CloseHandle(_hFile);rn return hBitmap;rn使用以上<em>代码</em>用内存映射的方法,创建一个大的位图,如果位图的尺寸太大的话,MapViewOfFile和CreateDIBSection都会<em>失败</em>,请各位专家指教,这时应该怎么处理?
CreateFile 打开符号链接 返回0;
通过winObj 查看有这个符号链接,但是<em>打开</em>的时候就是<em>返回</em>错误!!GetLastError 为1;
为什么失败
Set regset = CreateObject("WScript.Shell") 在win2000操作系统下,用.vbs文件或.htm文件均<em>失败</em>??
关于一个简单驱动程序的问题:CreateFile()返回失败
最近在尝试自己写个驱动程序,但是在用户态调用CreateFile()时总是<em>失败</em>,<em>返回</em>0xffffffff,请各路高手帮我找找问题所在,谢谢了。rnrn// 驱动<em>代码</em><em>代码</em>如下rnrn[code=C/C++]rn//rn// HelloWorldDrv.crn//rn#include "ntstatus.h"rn#include "ntddk.h"rn#include rn#include rn#define true 1rn#define false 0rn// const variablesrnconst WCHAR deviceNameBuffer [] = L"\\Device\\HelloWorldDevice";rnconst WCHAR dosDeviceNameBuffer [] = L"\\DosDevice\\HelloWorldDevice";rn// global pointer to our device objectrnPDEVICE_OBJECT g_helloWorldDevice;rn// This is our unload functionrnvoid OnUnload ( IN PDRIVER_OBJECT driverObject )rnrn UNICODE_STRING strDosDeviceNameUnicodeString;rn DbgPrint ( "OnUnload() called!!!!!!\n" );rn RtlInitUnicodeString ( &strDosDeviceNameUnicodeString, dosDeviceNameBuffer );rn // delete symbolic linkrn IoDeleteSymbolicLink ( &strDosDeviceNameUnicodeString );rn // delete device rn IoDeleteDevice ( driverObject->DeviceObject );rnrnrnNTSTATUS MyOpen ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIRP )rnrn DbgPrint ( "MyOpen() called!!!\n" );rn return STATUS_SUCCESS;rn rnrnNTSTATUS MyClose ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIRP )rnrn DbgPrint ( "MyClose() called!!!\n" );rn return STATUS_SUCCESS;rnrnrnNTSTATUS MyRead ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIRP )rnrn NTSTATUS ntStatus = STATUS_SUCCESS; rn DbgPrint ( "MyRead() called!!!!!!\n" ); rn return ntStatus;rnrnrnNTSTATUS MyWrite ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIRP )rnrn NTSTATUS ntStatus = STATUS_SUCCESS; rn DbgPrint ( "MyWrite() called!!!!!!\n" ); rn return ntStatus;rnrnrn// Entry functionrnNTSTATUS DriverEntry ( IN PDRIVER_OBJECT pDriverObject, rn IN PUNICODE_STRING theRegistryPath )rnrn //NTSTATUS ntStatus;rn UNICODE_STRING strDeviceNameUnicodeString;rn UNICODE_STRING strDosDeviceNameUnicodeString;rn NTSTATUS ntStatus;rn rn DbgPrint ( "DriverEntry() called!!!!!!\n" );rn rn // set up our namern RtlInitUnicodeString ( &strDeviceNameUnicodeString, deviceNameBuffer );rn RtlInitUnicodeString ( &strDosDeviceNameUnicodeString, dosDeviceNameBuffer ); rn // Initialize the pointer to the unload function in the driverObjectrn pDriverObject->DriverUnload = OnUnload; rn // set functionsrn pDriverObject->MajorFunction [ IRP_MJ_CREATE ] = MyOpen;rn pDriverObject->MajorFunction [ IRP_MJ_CLOSE ] = MyClose;rn pDriverObject->MajorFunction [ IRP_MJ_READ ] = MyRead;rn pDriverObject->MajorFunction [ IRP_MJ_WRITE ] = MyWrite; rn // create device rn ntStatus = IoCreateDevice ( pDriverObject, 0,// for driver extension &strDeviceNameUnicodeString, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, false,rn &g_helloWorldDevice ); rn if ( NT_SUCCESS( ntStatus ) )rn rn // create a symbolic link to the devicern IoCreateSymbolicLink ( & strDosDeviceNameUnicodeString, strDeviceNameUnicodeString );rn rn return STATUS_SUCCESS;rnrnrnrn//rn// SOURCESrn//rnTARGETNAME=HelloWorldDrvrnTARGETPATH=OBJrnTARGETTYPE=DRIVERrnSOURCES=HelloWorldDrv.crnrnrn//rn// MAKEFILErn//rn!INCLUDE $(NTMAKEENV)\makefile.defrnrnrn//rn// HelloWorldApp.crn//rn#include rn#include rnrnint main()rnrnrn HANDLE hFile;rn DWORD dwReturn;rnrn hFile = CreateFile("\\\\.\\HelloWorldDevice", rn GENERIC_WRITE, rn 0, rn NULL, rn OPEN_EXISTING, rn FILE_ATTRIBUTE_NORMAL,rn NULL);rnrn if( hFile == INVALID_HANDLE_VALUE )rn rn printf("create file failed!!!\n");rn rn elsern rn CloseHandle(hFile);rn rn return 0;rnrn[/code]rnrnrnrn
CreateFile 打开文件重新写入失败,但GetlastError没有失败提示,
我有一颗双亲树,顺序数组存放,要保存到文件里面。每次树被更新之后就要写到文件里面去,rnrn可是下面这个函数运行没有错误,但文件总是没有得到更新rnrn[code=c]rnint PtTree::SaveToFile(LPCTSTR Filename)rnrn// ::DeleteFile(Filename);rn//情况内容,rn HANDLE hIndex = ::CreateFile(rn Filenamern ,GENERIC_WRITErn ,0rn ,NULLrn ,TRUNCATE_EXISTINGrn ,FILE_ATTRIBUTE_NORMALrn ,NULL);rnrn//<em>打开</em>成功但就是没有把文件更新rn if( INVALID_HANDLE_VALUE == hIndex )rn rn ShowError();rn return 0;rn rn DWORD dwNumberOfBytes;rnrn ::SetFilePointer( hIndex, 0, 0 , FILE_BEGIN );rnrn //写入节点个数rn if(0 == WriteFile( hIndex, (LPVOID) &NodeCount, sizeof(NodeCount), &dwNumberOfBytes, NULL ) )rn rn ShowError();rn CloseHandle(hIndex);rn return 0 ;rn rnrn //写入叶子节点个数rn if(0 == WriteFile( hIndex, (LPVOID)&LeafCount, sizeof(LeafCount), &dwNumberOfBytes, NULL ) )rn rn ShowError();rn CloseHandle(hIndex);rn return 0 ;rn rnrn//写入顺序树信息 ,这里在单步的时候可以看到dwNumberOfBytes为500,但文件的大小还是原来的248Brn if(NodeCount && 0 == WriteFile( hIndex, (LPVOID)( &node), (NodeCount) * sizeof(PtNode), &dwNumberOfBytes, NULL ) )rn rn ShowError();rn CloseHandle(hIndex);rn return 0 ;rn rnrn //写入叶子数组rn if(LeafCount && 0 == WriteFile( hIndex, (LPVOID)(&Leaf), (LeafCount) * sizeof(int), &dwNumberOfBytes, NULL ) )rn rn ShowError();rn CloseHandle(hIndex);rn return 0 ;rn rn rn CloseHandle(hIndex);rnrn return 1;rnrn[/code]
VC CreateFile打开 带点文件夹d:\abc..\server.asp失败
VC CreateFile<em>打开</em> 带点文件夹d:\abc..\server.asp<em>失败</em>.rn说是系统 找不到路径.rn试过用Dos命令的copy也复制不出文件.rn我是想问下对类似d:\abc..\server.asprnVC<em>代码</em>应该怎么操作呢?
用CreateFile打开过滤驱动失败,这是怎么回事?
做了一个U盘过滤驱动,需要用DeviceIoControl和过滤驱动通信,在MFC exe程序中可以使用CreateFile<em>打开</em>并使用DeviceIoControl与过滤驱动通信。rnrn 但是在一个dll中却无法使用CreateFile<em>打开</em>驱动,我用GetLastError和FormatMessage跟踪,没有报错,说是操作成功完成,估计是权限不够吧。rnrnrn 但是过滤驱动的DriverEntry函数中,已经加了降低权限的<em>代码</em>,不知道<em>为什么</em>还是打不开?向大家请教rnrn#define USBFILTER_SYSDEVICE_NAME L"\\Device\\HTUsbFilter"rn#define USBFILTER_DOSDEVICE_NAME L"\\DosDevices\\HTUsbFilter"rnrn#pragma INITCODE rnextern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,rn IN PUNICODE_STRING RegistryPath)rnrn 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 rn MyDriverObject = DriverObject;rn // create control device objectrn RtlInitUnicodeString(&DeviceName, USBFILTER_SYSDEVICE_NAME);rn NtStatus = IoCreateDevice(DriverObject, rn 0, rn &DeviceName,rn FILE_DEVICE_DISK, rn 0,rn FALSE,rn &MyControlDeviceObject);rn if (!NT_SUCCESS(NtStatus))rn rn KdPrint((DRIVERNAME " - IoCreateDevice failed - %X\n", NtStatus));rn return NtStatus;rn rn rn NtStatus = ObOpenObjectByPointer(MyControlDeviceObject,rn 0,rn NULL,rn FILE_ALL_ACCESS,rn NULL,KernelMode,rn &CtlDevHandle);rn if(!NT_SUCCESS(NtStatus)) rn rn rn return NtStatus;rn rn ObDereferenceObject(MyControlDeviceObject);rn SecurityDescriptor = (PSECURITY_DESCRIPTOR)ExAllocatePool(NonPagedPool,sizeof(SECURITY_DESCRIPTOR));rn NtStatus = RtlCreateSecurityDescriptor(SecurityDescriptor,SECURITY_DESCRIPTOR_REVISION);rn if(!NT_SUCCESS(NtStatus)) rn rn KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject %8.8lX\n", DriverObject));rn return NtStatus;rn rn NtStatus = NtSetSecurityObject(CtlDevHandle,DACL_SECURITY_INFORMATION,SecurityDescriptor);rn if(!NT_SUCCESS(NtStatus)) rn rn return NtStatus;rn rn ZwClose(CtlDevHandle);rnrn // create symbol Linkrn RtlInitUnicodeString(&SymLinkName, USBFILTER_DOSDEVICE_NAME);rn NtStatus = IoCreateSymbolicLink(&SymLinkName, &DeviceName);rn if (!NT_SUCCESS(NtStatus)) rn rn KdPrint((DRIVERNAME " - IoCreateSymbolicLink failed - %X\n", NtStatus));rn IoDeleteDevice(MyControlDeviceObject);rn return NtStatus;rn rn 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 rn return STATUS_SUCCESS;rn // DriverEntryrnrnrndll中的相关<em>代码</em>:rn rnBOOL SendKeyUsernameToUsbfilter(char* Username,int len)rnrn BOOL bStatus;rn DWORD dwRet;rn int buflen = len;rn char keyUsername[64] = 0;rn HANDLE hHTUSBFILTERDevice = INVALID_HANDLE_VALUE;//scottrn rn memcpy(keyUsername,Username,len);rnrn //add notification to USBFILTERrn hHTUSBFILTERDevice = CreateFile(HTUSBFILTER_NAME,rn GENERIC_READ | GENERIC_WRITE,rn FILE_SHARE_READ | FILE_SHARE_WRITE,rn NULL,rn OPEN_EXISTING,rn 0,rn NULL);rn rn if(hHTIPSECDevice != INVALID_HANDLE_VALUE) rn rn bStatus = DeviceIoControl(hHTUSBFILTERDevice,rn IOCTL_USBFILTER_GET_USERNAME,rn keyUsername, rn buflen, rn NULL, rn 0,rn &dwRet, rn NULL);rn CloseHandle( hHTUSBFILTERDevice );rn if (!bStatus)rn rn MessageBox(NULL,"通知U盘过滤驱动<em>失败</em>-DeviceIoControl!","SendKeyUsernameToUsbfilter",0);rn rn MessageBox(NULL,"通知U盘过滤驱动成功!","SendKeyUsernameToUsbfilter",0);rn rn elsern rn// DWORD nErrorNo = GetLastError ( ); // 得到错误<em>代码</em>rn// LPSTR lpBuffer; rn// FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | rn// FORMAT_MESSAGE_IGNORE_INSERTS | rn// FORMAT_MESSAGE_FROM_SYSTEM,rn// NULL,rn// nErrorNo, // 此乃错误<em>代码</em>,通常在程序中可由 GetLastError()得之rn// LANG_NEUTRAL,rn// (LPTSTR) & lpBuffer,rn// 0 ,rn// NULL );rn// MessageBox(NULL,lpBuffer,0,0);rn// LocalFree (lpBuffer); rn MessageBox(NULL,"<em>打开</em>U盘过滤驱动<em>失败</em>-CreateFile!","SendKeyUsernameToUsbfilter",0);rn return FALSE;rn rn rn return TRUE;rnrnrnrn
连续两次调用CreateFile打开USB设备,第二次失败
连续两次用CreateFile<em>打开</em>USB设备,第一次以读的方式,第二次以写的方式。读方式<em>打开</em>成功,写方式<em>打开</em><em>失败</em>,调用GetLastError<em>返回</em>拒绝访问,但是我直接以写的方式<em>打开</em>,是成功的,这是<em>为什么</em>呢?
为什么win7下调用ReadProcessMemory()总是返回失败呢?
<em>代码</em>如下:rnHANDLE hProc = OpenProcess(PROCESS_VM_READ,FALSE,dwPID);rn if(hProc)rn rn DWORD dwRet = -1;rn DWORD dwAddr = *(DWORD*)((DWORD)GetCommandLine + 1);rn TCHAR tcBuf[buffLen];rn DWORD dwRead = 0; rnrn [color=#0000FF]ReadProcessMemory[/color](hProc,(LPVOID)dwAddr,&dwAddr,4,&dwRead);rn rnrn在xp、server2003上都没问题。rn
vs2008中用QT调用createfile打开分区失败的原因
vs2008中用QT调用<em>createfile</em><em>打开</em>分区<em>失败</em>的原因rn我在vs2008中编译一个测试<em>代码</em>,<em>打开</em>一个分区,没有问题!rnrn测试通过后,我在vs2008里建立了一个QT工程,然后把测试<em>代码</em>嵌入里面,希望可以在图形界面中选择需要<em>打开</em>的分区,编译通过,但死活都是<em>打开</em>分区<em>失败</em>!rnrn<em>打开</em>分区的<em>代码</em>如下:rn_TCHAR volumePath[7];rn_sntprintf(volumePath, 6, _T("\\\\.\\%c:"), volume);rnvolumePath[6] = _T('\0');rnhVolume = CreateFile((LPCTSTR )volumePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,rnNULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);rnrnrn查找<em>返回</em>的错误<em>代码</em>显示的错误是:rn刚开始的错误码是2:意思是找不到<em>打开</em>的文件rn换了好几个分区来<em>打开</em>时变成了这个错误:@err,hr 0x0000007b 文件名、目录名或卷标语法不正确。 unsigned longrnvolumePath的值显示是:\\.\\C:rn_TCHAR的大小是1rn不知道qt对这种反斜杠的文件名:\\.\\C: 有没有敏感,以致打不开分区。rnrn望知道错误的大侠指点rnrnqt4.6.2 vs2008版
CreateFile()、GetCommState()、SetCommState()打开串口失败的原因或许是这个
博主初次在CSDN发帖,如果有什么写的不好的地方请多多见谅! 对于一般新手而言,直接使用CreateFile函数时,通常会出现以下错误: 函数 "char *" 类型的实参与 "LPCWSTR" 类型的形参不兼容 例如: bool openport(char *portname)//<em>打开</em>串口 { hComm = CreateFile(portname, //串口号  //GENERI
CreateFile打开串口失败 GetLastError()返回值为2
编译环境为C++ builder 2009rn<em>代码</em>如下:rnBOOL CSerial::Open( int nPort, int nBaud )rnrn if( m_bOpened ) return( TRUE );rnrn char szPort[15];rn char szComParams[50];rn DCB dcb;rnrn if(nPort > 9)rn wsprintf( (wchar_t *)szPort, (wchar_t *)"\\\\.\\COM%d", nPort );rn elsern wsprintf( (wchar_t *)szPort,(wchar_t *) "COM%d", nPort );rn [color=#FF6600]m_hIDComDev = CreateFile( (wchar_t *)szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );[/color]rn if( m_hIDComDev == NULL ) return( FALSE );rnrn memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );rn memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );rnrn COMMTIMEOUTS CommTimeOuts;rn CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;rn CommTimeOuts.ReadTotalTimeoutMultiplier = 0;rn CommTimeOuts.ReadTotalTimeoutConstant = 0;rn CommTimeOuts.WriteTotalTimeoutMultiplier = 0;rn CommTimeOuts.WriteTotalTimeoutConstant = 5000;rn SetCommTimeouts( m_hIDComDev, &CommTimeOuts );rnrn sprintf( szComParams, "COM%d:%d,n,8,1", nPort, nBaud );rnrn m_OverlappedRead.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );rn m_OverlappedWrite.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );rnrn dcb.DCBlength = sizeof( DCB );rn GetCommState( m_hIDComDev, &dcb );rn dcb.BaudRate = nBaud;rn dcb.ByteSize = 8;rn dcb.fRtsControl = RTS_CONTROL_DISABLE; //RTS_CONTROL_ENABLE; // set RTS bit high!rn unsigned char ucSet;rn ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 );rn ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 );rn ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 );rn if( !SetCommState( m_hIDComDev, &dcb ) ||rn !SetupComm( m_hIDComDev, 10000, 10000 ) ||rn m_OverlappedRead.hEvent == NULL ||rn m_OverlappedWrite.hEvent == NULL )rn DWORD dwError = GetLastError();rn if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );rn if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );rn CloseHandle( m_hIDComDev );rn return( FALSE );rn rnrn m_bOpened = TRUE;rnrn return( m_bOpened );rnrnrnrnrn想<em>打开</em>串口 使用命令AtCom.open(1,115200) 逐步调试的时候发现CreateFile<em>失败</em> 用GetLastError 显示错误<em>代码</em>为2rn请教如何修改? 谢谢好心人
LoadImage返回失败
CString str = "D:\\zxh\\111\\res\\sa.bmp";rnHBITMAP bim = (HBITMAP)LoadImage(AfxGetInstanceHandle(), str, IMAGE_BITMAP, 0,0,0);rnif(bim == NULL)rnrn DWORD errno = GetLastError();rn return;rnrn总是<em>返回</em>ERROR_RESOURCE_NAME_NOT_FOUND错误,rnvc里原来LoadImage最后一个参数用LR_LOADFROMFILE,但是在wince里就编译不通过,LR_LOADFROMFILE不认,<em>为什么</em>?rn那我该怎么用??rn我就是想做个类,类里面有个函数是画bmp的.CClientDC的指针也传到了类里面.是不是AfxGetInstanceHandle(),有问题呢rn
调用返回数据失败。。
char *StrAdd()rnrnchar *lpBuffer=NULL;rn..............rnreturn lpBuffer;rnrnint APIENTRY WinMain(HINSTANCE hInstance,rn HINSTANCE hPrevInstance,rn LPSTR lpCmdLine,rn int nCmdShow)rnrnMessageBox(NULL, StrAdd(), "0000", MB_OK);的时候总是<em>失败</em>。。。怎么回事啊rn
页面验证失败返回
我做了一个注册页面,想要的结果是:在验证<em>失败</em>后,自动跳回注册页面,并且之前填写的资料还在。rn这个怎么做?
VS2005 fopen返回失败
我原装copy了自己的解决方案到另一个目录,debug和release都可编译成功,但运行<em>失败</em>了。在debug版本跟踪,可发现时fopen<em>返回</em><em>失败</em>了。fopen参数使用"filename.txt"这样的相对路径名,以前运行好好的,copy了一下怎么就挂了呢?在debug版本设置了“工作目录”(.../debug)后,debug版本可运行成功,但release版本不行。把debug版本可执行程序copy到release目录下,也可运行成功。rnrn现在的结论是:rn(1)debug版本使用fopen绝对路径参数,可成功!把该版本exe拷贝到release目录也可成功。rn(2)使用fopen相对路径参数,debug和release都不行!rnrn我对VS2005不熟,一些问题摸不着头脑,还望高人指点迷津!
查询天气,返回失败
[code=Java]rnprivate static final String GOOGLE_API_URL = "http://www.google.com/ig/api?weather=";rn private static final String NETWORK_ERROR = "Network error!";rnrn...rnrn // Get weather informationrn public String getWetherByCity(String city) rn HttpClient httpClient = new DefaultHttpClient();rn HttpContext localContent = new BasicHttpContext();rn HttpGet httpGet = new HttpGet(GOOGLE_API_URL + city);rn rn try rn HttpResponse response = httpClient.execute(httpGet, localContent);rn if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) rn httpGet.abort();rn else rn HttpEntity httpEntity = response.getEntity();rn return parseWeather(httpEntity.getContent());rn rn rn catch (Exception e) rn Log.e(TAG, "Failed to get weather information.", e);rn finally rn httpClient.getConnectionManager().shutdown();rn rn rn return NETWORK_ERROR; // <em>为什么</em>会执行到这里<em>返回</em>呢?连不上网rn [/code]rn问题,执行查询天气<em>失败</em>,安装到可以GPRS上网的手机上也<em>失败</em>,是什么原因呢?是不是需要设置上网方式?还是怎么回事呢?多谢!!
pthread_create 返回失败
rn同样一份<em>代码</em>,在cygwin和linux下执行成功,HP-UX下执行<em>失败</em>。rn int nRet = 0;rn nRet = pthread_create(&tid, NULL, nThreadFunc, NULL);rn if( nRet != 0 )rnrn printf("++++++[%d]++++++\n",nRet );rn perror("pthread_create");rnrnrn<em>代码</em>如上,linux下 nRet 的值为0,即上段<em>代码</em>执行成功。rnhp-ux下执行结果为:rn++++++[251]++++++rnpthread_create: Error 0rnrnrn请问高手这个<em>返回</em>值是怎么回事 ?
返回类型失败
在web service中<em>为什么</em>不能<em>返回</em>DataTable的数据类型。
update 失败返回码?
在Oracle中执行一条update语句,如果符合where条件的数据不存在,会有一个特定的错误码<em>返回</em>吗?
c# 返回SqlDataReader失败
public SqlDataReader readData(string sql)rn rn tryrn rn conn.Open();rn cmd = new SqlCommand(sql, conn);rn rs = cmd.ExecuteReader();rn //while (rs.Read())rn //rn // Console.WriteLine(rs[0].ToString());rn //rn rn catch (Exception e)rn rn Console.WriteLine(e.Message);rn return null;rn rn return rs;rn rn<em>为什么</em>在这个里边用循环就可以提取到数据,但是下面这样就取不出出来数据.rn SqlDataReader drs = sdbc.readData("select * from aabbcc");rn tryrn rn while (drs.Read())rn rn Console.WriteLine(drs["0"].ToString());rn rn rn catchrn rn
acmStreamOpen 失败返回 MMSYSERR_NOTSUPPORTED
音频转换从 WAVE_FORMAT_IMA_ADPCM 到 PCM ,执行到这个函数时<em>返回</em><em>失败</em>。前面已经通过 acmFormatEnum 获取到了 Formatrnrn[code=c]rn HACMDRIVER had = NULL;rn mmr = acmDriverOpen(&had, hadid, 0);rn if (mmr) rn // AfxMessageBox("Failed to open driver\n");rn return 0;rn rn rn // open the conversion streamrn // Note the use of the ACM_STREAMOPENF_NONREALTIME flag. Without thisrn // some software compressors will report error 512 - not possiblern mmr = acmStreamOpen(&hstr,rn had, // driver handlern pwfPCM, // source formatrn pwfDrv, // destination formatrn NULL, // no filterrn NULL, // no callbackrn 0, // instance data (not used)rn ACM_STREAMOPENF_NONREALTIME ); // flagsrn[/code]
.NET Reflector 7.4.0.180 破解注册版下载
破解说明: 将压缩包内“Crack”文件夹内的文件,拷贝到程序所在文件夹,覆盖同名文件,即可完成破解 ^_^ 相关下载链接:[url=//download.csdn.net/download/gattaca2011/3838316?utm_source=bbsseo]//download.csdn.net/download/gattaca2011/3838316?utm_source=bbsseo[/url]
DIV CSS布局大全.rar下载
网站的布局决定网站的好看才能留住浏览者的眼球你还不会吗?div的布局是现在主流的一部分本书教你如何对网站使用div布局 相关下载链接:[url=//download.csdn.net/download/a39947540/2685497?utm_source=bbsseo]//download.csdn.net/download/a39947540/2685497?utm_source=bbsseo[/url]
WIN7中安装VC6.0下载
WIN7与VC6.0的兼容解决方案。解决了VC与WIN7系统不兼容的问题。 相关下载链接:[url=//download.csdn.net/download/fallingleaf/4061888?utm_source=bbsseo]//download.csdn.net/download/fallingleaf/4061888?utm_source=bbsseo[/url]
我们是很有底线的