WriteFile() Windows7下有关问题

WriteFile() Windows7下问题
我最近在做一个写SD卡的程序,直接调用了WriteFile()函数。这个程序在XP下使用正常,但是到了Win7下面,函数返回5(ERROR_ACCESS_DENIED)。Google了一下,发现Win7出于安全考虑不支持直接写这些逻辑磁盘了。必须要先卸载什么的,我对文件系统这边没什么研究,不知道怎么弄了,哪位有弄过的,给点提示,小弟先谢谢了。


bool CSD_CARDDlg::write_sd_sector(char* drivename, U32 sector_index, U32 sector_num, U8* buffer)
{
bool  b_ret = false;
DWORD dwCB;
DWORD dwPtr;
BOOL bResult;
DWORD dwError;
DWORD bytes;

HANDLE hDev = CreateFile(drivename, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);

if(hDev == INVALID_HANDLE_VALUE)
{
goto error;
}

dwPtr = SetFilePointer(hDev, sector_index * SD_SECTOR_SIZE, 0, FILE_BEGIN);
if (dwPtr == INVALID_SET_FILE_POINTER)
{
CloseHandle(hDev);
goto error;
}

bResult = WriteFile(hDev, buffer, SD_SECTOR_SIZE * sector_num, &dwCB, 0);
if (!bResult)
{
    // deal with the error code 
    switch (dwError = GetLastError())
    {
        case ERROR_HANDLE_EOF:
        {
            // we're reached the end of the file 
            // during the call to ReadFile

CloseHandle(hDev);
goto error;
        }

default:
TRACE("%d: Unknown error when WriteFile dwError = %d\n", __LINE__, dwError);
break;
        // deal with other error cases 
    }
}

if(dwCB != SD_SECTOR_SIZE * sector_num)
{
CloseHandle(hDev);
goto error;
}

CloseHandle(hDev);
b_ret = true;

error:
if(b_ret == false)
TRACE("%d: write_sd_sector error\n", __LINE__);
return b_ret;

}

------解决方案--------------------
不懂,等待大侠出手!
------解决方案--------------------
http://topic.****.net/u/20110408/16/8bf514d1-2bc1-479c-9cc0-019a061e0804.html