WinCE下文件操作内存泄漏的问题
程序执行了反复创建文件和删除文件的操作。
在winXP环境下运行没有问题(或者也可能是我没有发现问题。)
在WinCE环境下会内存泄漏。
偶是菜鸟,第一次玩,向各位高手求救阿!
以下代码:
===================================================
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <atlbase.h>
long times = 20000;
void test_Files(int Count,FILE* pf) {
HANDLE hFile;
BOOL bFileClose;
hFile = CreateFile( TEXT("myfile.txt"),
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
printf("Could not open file (error %d)\n", GetLastError());
return;
}
bFileClose = CloseHandle(hFile);
if (bFileClose == NULL)
{
printf("(E)Cannot close the file.\n");
return ;
}
USES_CONVERSION;
if(DeleteFile(A2CT((LPSTR)"myfile.txt")) == 0)
{
printf("Could not delete file!\n");
return;
}
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow )
{
int nCnt = 0;
FILE *pf = NULL;
for(nCnt = 0; nCnt < times; nCnt++)
{
test_Files(nCnt, pf);
}
return 0;
}