Jedi:需要 GUID_DEVINTERFACE_IMAGE 的价值:TGUID
Jedi: Needing of value for GUID_DEVINTERFACE_IMAGE: TGUID
早上好,
我想要获取计算机中网络摄像头的总数,并翻译在 C++ 中找到的源代码(code is here) 到 Delphi,如下所示:
const
MAX_PATH = 260;
CR_SUCCESS =[=11=]000000;
type
HDevInfo = Pointer; { a pointer to a HID device info structure }
THDEVINFO = Pointer;
PSP_DevInfo_Data = ^TSP_DevInfo_Data;
SP_DEVINFO_DATA = packed record
cbSize: DWORD;
ClassGuid: TGUID;
DevInst: DWORD;
Reserved: LongWord;
end;
TSP_DevInfo_Data = SP_DEVINFO_DATA;
PDEVPROPKEY = ^TDEVPROPKEY;
DEVPROPKEY = packed record
fmtid : TGUID ;
pid : Pointer;
end;
TDEVPROPKEY = DEVPROPKEY;
DEVPROPTYPE = Pointer;
PCWSTR = PWCHAR;
TDEVINST = DWord;
TPOSVERSIONINFOW = ^TOSVERSIONINFOW;
TOSVERSIONINFOW = packed record
dwOSVersionInfoSize : DWORD ;
dwMajorVersion : DWORD ;
dwMinorVersion : DWORD ;
dwBuildNumber : DWORD ;
dwPlatformId : DWORD ;
szCSDVersion : array[0..127] of wchar;
end;
function SetupDiGetDeviceProperty(DeviceInfoSet: THDEVINFO; DeviceInfoData: PSP_DEVINFO_DATA; const PropertyKey: PDEVPROPKEY; var PropertyType:DEVPROPTYPE; PropertyBuffer:PBYTE;PropertyBufferSize:DWORD; RequiredSize:PDWORD; Flags:DWORD): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiGetDevicePropertyW';
function SetupDiGetClassDevsW(const ClassGuid: PGUID; Enumerator: PCWSTR; hwndParent: HWND; Flags: DWORD): THDEVINFO; stdcall; external 'Setupapi.DLL' name 'SetupDiGetClassDevsW';
function SetupDiGetClassDevsA(ClassGuid: PGUID; const Enumerator: PAnsiChar;
hwndParent: HWND; Flags: DWORD): THandle; stdcall; external 'SetupApi.dll';
function SetupDiEnumDeviceInfo(DeviceInfoSet: THDEVINFO; MemberIndex: DWORD; DeviceInfoData: PSP_DEVINFO_DATA): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiEnumDeviceInfo';
function CM_Get_Device_IDW(DeviceInstanceHandle: TDEVINst; Buffer:PCWSTR; Bufferlen : ULONG; ulFlags:ULONG): DWORD; stdcall; external 'Setupapi.DLL' name 'CM_Get_Device_IDW';
function SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet: THDEVINFO; const DeviceInfoData: SP_DevInfo_Data; Property_: DWORD; var PropertyRegDataType: DWORD; PropertyBuffer: PBYTE; PropertyBufferSize: DWORD; var RequiredSize: DWORD): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiGetDeviceRegistryPropertyW';
function GetVersionExW(OsVersion:TPOSVERSIONINFOW): BOOL; stdcall; external 'Kernel32.dll' name 'GetVersionExW';
const
DIGCF_PRESENT = [=11=]000002;
DIGCF_ALLCLASSES = [=11=]000004;
DIGCF_PROFILE = [=11=]000008;
DIGCF_DEVICEINTERFACE = [=11=]000010;
INVALID_HANDLE_VALUE = DWORD($FFFFFFFF);
MAX_DEVICE_ID_LEN = 200;
SPDRP_DEVICEDESC = ([=11=]000000) ;
DEVPKEY_Device_BusReportedDeviceDesc : TDEVPROPKEY = (fmtid : '{540b947e-8b40-45bc-a8a2-6a0b894cbda2}' ; pid : pointer(4) );
implementation
function GetNumCam: integer;
var
MemberIndex: integer;
dev: HDEVINFO;
DeviceInfoData: SP_DEVINFO_DATA;
begin
DeviceInfoData.cbSize := sizeof(DeviceInfoData);
dev := SetupDiGetClassDevsA(@GUID_DEVINTERFACE_IMAGE, nil, nil, DIGCF_PRESENT);
if dev = nil then begin
//raise exception.Create('Nenhum dispositivo encontrado');
exit;
end
else
while SetupDiEnumDeviceInfo(dev,MemberIndex, @DeviceInfoData) do
begin
MemberIndex:= MemberIndex + 1;
end;
Result:= MemberIndex;
end;
但是我很难在 Delphi 中找到 GUID_DEVINTERFACE_IMAGE
的值,然后为这个常量分配这个值。我在 (this unit) 中看到,但没有这个常量,因为我抓住了价值。
有人知道这个常量的确切值吗?
提前致谢。
可以在documentation中找到该值:
{0x6bdd1fc6L, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08,
0x00, 0x2b, 0xe2, 0x09, 0x2f}
在 Delphi 中,您可以这样声明:
const
GUID_DEVINTERFACE_IMAGE: TGUID = (
D1:bdd1fc6; D2:0f; D3:d0; D4:($be, $c7, , [=10=], b, $e2, , f)
);
或者像这样:
const
GUID_DEVINTERFACE_IMAGE: TGUID = '{6bdd1fc6-810f-11d0-bec7-08002be2092f}';
早上好,
我想要获取计算机中网络摄像头的总数,并翻译在 C++ 中找到的源代码(code is here) 到 Delphi,如下所示:
const
MAX_PATH = 260;
CR_SUCCESS =[=11=]000000;
type
HDevInfo = Pointer; { a pointer to a HID device info structure }
THDEVINFO = Pointer;
PSP_DevInfo_Data = ^TSP_DevInfo_Data;
SP_DEVINFO_DATA = packed record
cbSize: DWORD;
ClassGuid: TGUID;
DevInst: DWORD;
Reserved: LongWord;
end;
TSP_DevInfo_Data = SP_DEVINFO_DATA;
PDEVPROPKEY = ^TDEVPROPKEY;
DEVPROPKEY = packed record
fmtid : TGUID ;
pid : Pointer;
end;
TDEVPROPKEY = DEVPROPKEY;
DEVPROPTYPE = Pointer;
PCWSTR = PWCHAR;
TDEVINST = DWord;
TPOSVERSIONINFOW = ^TOSVERSIONINFOW;
TOSVERSIONINFOW = packed record
dwOSVersionInfoSize : DWORD ;
dwMajorVersion : DWORD ;
dwMinorVersion : DWORD ;
dwBuildNumber : DWORD ;
dwPlatformId : DWORD ;
szCSDVersion : array[0..127] of wchar;
end;
function SetupDiGetDeviceProperty(DeviceInfoSet: THDEVINFO; DeviceInfoData: PSP_DEVINFO_DATA; const PropertyKey: PDEVPROPKEY; var PropertyType:DEVPROPTYPE; PropertyBuffer:PBYTE;PropertyBufferSize:DWORD; RequiredSize:PDWORD; Flags:DWORD): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiGetDevicePropertyW';
function SetupDiGetClassDevsW(const ClassGuid: PGUID; Enumerator: PCWSTR; hwndParent: HWND; Flags: DWORD): THDEVINFO; stdcall; external 'Setupapi.DLL' name 'SetupDiGetClassDevsW';
function SetupDiGetClassDevsA(ClassGuid: PGUID; const Enumerator: PAnsiChar;
hwndParent: HWND; Flags: DWORD): THandle; stdcall; external 'SetupApi.dll';
function SetupDiEnumDeviceInfo(DeviceInfoSet: THDEVINFO; MemberIndex: DWORD; DeviceInfoData: PSP_DEVINFO_DATA): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiEnumDeviceInfo';
function CM_Get_Device_IDW(DeviceInstanceHandle: TDEVINst; Buffer:PCWSTR; Bufferlen : ULONG; ulFlags:ULONG): DWORD; stdcall; external 'Setupapi.DLL' name 'CM_Get_Device_IDW';
function SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet: THDEVINFO; const DeviceInfoData: SP_DevInfo_Data; Property_: DWORD; var PropertyRegDataType: DWORD; PropertyBuffer: PBYTE; PropertyBufferSize: DWORD; var RequiredSize: DWORD): BOOL; stdcall; external 'Setupapi.DLL' name 'SetupDiGetDeviceRegistryPropertyW';
function GetVersionExW(OsVersion:TPOSVERSIONINFOW): BOOL; stdcall; external 'Kernel32.dll' name 'GetVersionExW';
const
DIGCF_PRESENT = [=11=]000002;
DIGCF_ALLCLASSES = [=11=]000004;
DIGCF_PROFILE = [=11=]000008;
DIGCF_DEVICEINTERFACE = [=11=]000010;
INVALID_HANDLE_VALUE = DWORD($FFFFFFFF);
MAX_DEVICE_ID_LEN = 200;
SPDRP_DEVICEDESC = ([=11=]000000) ;
DEVPKEY_Device_BusReportedDeviceDesc : TDEVPROPKEY = (fmtid : '{540b947e-8b40-45bc-a8a2-6a0b894cbda2}' ; pid : pointer(4) );
implementation
function GetNumCam: integer;
var
MemberIndex: integer;
dev: HDEVINFO;
DeviceInfoData: SP_DEVINFO_DATA;
begin
DeviceInfoData.cbSize := sizeof(DeviceInfoData);
dev := SetupDiGetClassDevsA(@GUID_DEVINTERFACE_IMAGE, nil, nil, DIGCF_PRESENT);
if dev = nil then begin
//raise exception.Create('Nenhum dispositivo encontrado');
exit;
end
else
while SetupDiEnumDeviceInfo(dev,MemberIndex, @DeviceInfoData) do
begin
MemberIndex:= MemberIndex + 1;
end;
Result:= MemberIndex;
end;
但是我很难在 Delphi 中找到 GUID_DEVINTERFACE_IMAGE
的值,然后为这个常量分配这个值。我在 (this unit) 中看到,但没有这个常量,因为我抓住了价值。
有人知道这个常量的确切值吗?
提前致谢。
可以在documentation中找到该值:
{0x6bdd1fc6L, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f}
在 Delphi 中,您可以这样声明:
const
GUID_DEVINTERFACE_IMAGE: TGUID = (
D1:bdd1fc6; D2:0f; D3:d0; D4:($be, $c7, , [=10=], b, $e2, , f)
);
或者像这样:
const
GUID_DEVINTERFACE_IMAGE: TGUID = '{6bdd1fc6-810f-11d0-bec7-08002be2092f}';