我用vs2005编译wince5.0板子的程序,调用windows.h 出现下面错误,怎么回事

我用vs2005编译wince5.0板子的程序,调用windows.h 出现下面错误,怎么回事,第1张

这个问题看着内容很多,其实可能问题要改动的很少,但是要找到地方却是很难的,这么多问题,什么少个逗号星号什么的这么多,一般是宏定义顺序不对,由此可能是头文件包含顺序不对,或者#if #else #endif 和#ifdef #ifndef这些开关的逻辑不对,当然如果你犯了括号不匹配的问题我就只能无语了,这个你只能一步步回溯了,如,你先看winnt.h,'PCONTEXT'在哪里,为什么没有定义,你这显示是在2976,应该是个结构体类型,那么是这个结构体类型没被定义,你再去看这个,是被什么宏开关控制了,再跟这个宏开关,等等,看到最后你会发现某个宏定义在一个文件里面,但是这个文件的位置在后面,导致某结构无法识别,所以你要把头文件提前,具体的只搭慎能你自己找了仿并

给你个例子

a.h

#ifdef BBB

typedef struct a{

int x

}STRCT_A

#endif

b.h

#define BBB

c.c

#include "a.h"

#include "b.h"

#ifdef BBB

STRCT_A sa = {0}

#endif

这里c里面肯定编译失败,因为你先include a.h,然后发现没有定义BBB,所以没有STRCT_A这个结构,然后你又include b.h,所以在c里面备枝迹有STRCT_A sa = {0};这行,然后就不认识STRCT_A,所以后面就有各种错了 ,解决的方法就是在c.c里include的顺序换一下就可以了

1、行孙添加一个对话框资源,假设ID是IDD_MYDIALOG

2、为对话框添加窗口过程函数,类似MainDlgProc,假设租带档为MyDlgProc

3、再需要对话框的弊乱地方DialogBox(hInst,MAKEINTRESOURCE( IDD_MYDIALOG ), NULL, MyDlgProc )

没有文件列表,只能枚举所尘郑有文件,再根据文件的属性判断是文件或者文件夹。

下面是MSDN上的完整例子

#include <派键颂windows.h>

#include <tchar.h>

#include <stdio.h>

#include <strsafe.h>

#pragma comment(lib, "User32.lib")

void DisplayErrorBox(LPTSTR lpszFunction)

int _tmain(int argc, TCHAR *argv[])

{

WIN32_FIND_DATA ffd

LARGE_INTEGER filesize

TCHAR szDir[MAX_PATH]

size_t length_of_arg

HANDLE hFind = INVALID_HANDLE_VALUE

DWORD dwError=0

// If the directory is not specified as a command-line argument,

// print usage.

if(argc != 2)

{

_tprintf(TEXT("\nUsage: %s <directory name>\n"), argv[0])

return (-1)

}

// Check that the input path plus 3 is not longer than MAX_PATH.

// Three characters are for the "\*" plus NULL appended below.

StringCchLength(argv[1], MAX_PATH, &length_of_arg)

if (length_of_arg >(MAX_PATH - 3))

{

_tprintf(TEXT("\nDirectory path is too long.\n"))

return (-1)

}

_tprintf(TEXT("\nTarget directory is %s\n\n"), argv[1])

// Prepare string for use with FindFile functions. First, copy the

// string to a buffer, then append '\*' to the directory name.

StringCchCopy(szDir, MAX_PATH, argv[1])

StringCchCat(szDir, MAX_PATH, TEXT("\\亮谈*"))

// Find the first file in the directory.

hFind = FindFirstFile(szDir, &ffd)

if (INVALID_HANDLE_VALUE == hFind)

{

DisplayErrorBox(TEXT("FindFirstFile"))

return dwError

}

// List all the files in the directory with some info about them.

do

{

if (ffd.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)

{

_tprintf(TEXT(" %s <DIR>\n"), ffd.cFileName)

}

else

{

filesize.LowPart = ffd.nFileSizeLow

filesize.HighPart = ffd.nFileSizeHigh

_tprintf(TEXT(" %s %ld bytes\n"), ffd.cFileName, filesize.QuadPart)

}

}

while (FindNextFile(hFind, &ffd) != 0)

dwError = GetLastError()

if (dwError != ERROR_NO_MORE_FILES)

{

DisplayErrorBox(TEXT("FindFirstFile"))

}

FindClose(hFind)

return dwError

}

void DisplayErrorBox(LPTSTR lpszFunction)

{

// Retrieve the system error message for the last-error code

LPVOID lpMsgBuf

LPVOID lpDisplayBuf

DWORD dw = GetLastError()

FormatMessage(

FORMAT_MESSAGE_ALLOCATE_BUFFER |

FORMAT_MESSAGE_FROM_SYSTEM |

FORMAT_MESSAGE_IGNORE_INSERTS,

NULL,

dw,

MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),

(LPTSTR) &lpMsgBuf,

0, NULL )

// Display the error message and clean up

lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,

(lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR))

StringCchPrintf((LPTSTR)lpDisplayBuf,

LocalSize(lpDisplayBuf) / sizeof(TCHAR),

TEXT("%s failed with error %d: %s"),

lpszFunction, dw, lpMsgBuf)

MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK)

LocalFree(lpMsgBuf)

LocalFree(lpDisplayBuf)

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12211086.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存