I use VC wrote a function in DLL:
extern "C" __declspec(dllexport) HRESULT GetDiskType(INT64* nTypeRet, LPWSTR szDisk)
{
USES_CONVERSION;
CString strDisk = CW2CT(szDisk);
*nTypeRet = GetDriveType(strDisk);
return TRUE;
}
I inovke it in inno-setup:
procedure InitializeWizard();
var nDrType:any;
begin
GetDiskType(nDrType, 'D:\\');
//MsgBox(IntToStr(nDrType), mbInformation, MB_OK);
if (nDrType=3) or (nDrType=6) then
begin
WizardForm.DirEdit.Text := 'D:\\{#MyAppPublisher}\{#MyAppName}';
end;
end;
when running, it show errors:write of address 00000000