[英]Unhandled Exception as at 0x6ececafa in 0xC0000005 : Access violation writing location 0x00000000
Getting exception in the following code. 在以下代码中获取异常。
HRESULT GetRemovableDrive(
__out LPDWORD lpdwRemovableDriveCount,
__out CHAR* szRemovableDrive )
{
INT iDriveCnt = 0;
CHAR TempDrive[ MAX_PATH ] = { TEXT('\0') };
hResult = CheckDriveReady( tzDriveName, &bIsDeviceReady );
if ( !hResult && TRUE == bIsDeviceReady )
{
//
// Copy drive name
//
strcpy_s ( TempDrive, tzDriveName );
memcpy(szRemovableDrive + iDriveCnt, TempDrive, 1);
iDriveCnt++;
( *lpdwRemovableDriveCount )++;
} // if
}
Getting exception while performing the memcpy as unhandled exception :Access violation writing location 0x00000000. 在执行memcpy时获取异常作为未处理的异常:访问冲突写入位置0x00000000。
The message is pretty clear. 消息很清楚。 You are writing to address 0 on the call to
memcpy()
. 您正在调用
memcpy()
写入地址0。 That means that szRemovableDrive
and iDriveCnt
are both 0 since that's the write destination address. 这意味着
szRemovableDrive
和iDriveCnt
均为0,因为这是写入目标地址。 The caller is likely passing in a NULL pointer to GetRemoveableDrive()
for that parameter. 调用者可能
GetRemoveableDrive()
NULL指针传递给该参数的GetRemoveableDrive()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.