haijie1223 Posted April 11, 2018 Share Posted April 11, 2018 How to create an IDXGIFactory object by ObjCreateInterface ? ObjCreateInterface(CLSID,IID) The IDXGIFactory Interface IID:{7B7166EC-21C7-44AE-B21A-C9AE321AE369},but the CLSID do not find。 How to create it? Link to comment Share on other sites More sharing options...
Danyfirex Posted April 13, 2018 Share Posted April 13, 2018 Hello. I think you need to do something like this: Local Const $sTag_IDXGIFactory="EnumAdapters hresult(uint*;ptr*); MakeWindowAssociation hresult(hwnd;uint); GetWindowAssociation hresult(hwnd*); CreateSwapChain hresult(ptr;ptr;ptr*); CreateSoftwareAdapter hresult(hwnd;ptr*);" Local Const $sIID_IDXGIFactory = "{7b7166ec-21c7-44ae-b21a-c9ae321ae369}" Local $tRIID_IDXGIFactory = _WinAPI_CLSIDFromString($sIID_IDXGIFactory) Local $hDll = DllOpen("DXGI.dll") Local $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0) Local $pIDXGIFactory = $aRet[2] Local $oDXGIFactory=ObjCreateInterface($pIDXGIFactory,$sIID_IDXGIFactory,$sTag_IDXGIFactory) ConsoleWrite(IsObj($oDXGIFactory) & @CRLF) Func _WinAPI_CLSIDFromString($sGUID) Local $tGUID = DllStructCreate('ulong Data1;ushort Data2;ushort Data3;byte Data4[8]') Local $iRet = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $sGUID, 'ptr', DllStructGetPtr($tGUID)) If (@error) Or ($iRet[0]) Then Return SetError(@error, @extended, 0) EndIf Return $tGUID EndFunc ;==>_WinAPI_CLSIDFromString Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
haijie1223 Posted April 14, 2018 Author Share Posted April 14, 2018 @Danyfirex Good!Thank you! Link to comment Share on other sites More sharing options...
nightwatcher Posted April 14, 2018 Share Posted April 14, 2018 9 hours ago, Danyfirex said: Hello. I think you need to do something like this: Local Const $sTag_IDXGIFactory="EnumAdapters hresult(uint*;ptr*); MakeWindowAssociation hresult(hwnd;uint); GetWindowAssociation hresult(hwnd*); CreateSwapChain hresult(ptr;ptr;ptr*); CreateSoftwareAdapter hresult(hwnd;ptr*);" Local Const $sIID_IDXGIFactory = "{7b7166ec-21c7-44ae-b21a-c9ae321ae369}" Local $tRIID_IDXGIFactory = _WinAPI_CLSIDFromString($sIID_IDXGIFactory) Local $hDll = DllOpen("DXGI.dll") Local $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0) Local $pIDXGIFactory = $aRet[2] Local $oDXGIFactory=ObjCreateInterface($pIDXGIFactory,$sIID_IDXGIFactory,$sTag_IDXGIFactory) ConsoleWrite(IsObj($oDXGIFactory) & @CRLF) Func _WinAPI_CLSIDFromString($sGUID) Local $tGUID = DllStructCreate('ulong Data1;ushort Data2;ushort Data3;byte Data4[8]') Local $iRet = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $sGUID, 'ptr', DllStructGetPtr($tGUID)) If (@error) Or ($iRet[0]) Then Return SetError(@error, @extended, 0) EndIf Return $tGUID EndFunc ;==>_WinAPI_CLSIDFromString Saludos Nice show! this problem also confuse me along time. Link to comment Share on other sites More sharing options...
haijie1223 Posted April 14, 2018 Author Share Posted April 14, 2018 @Danyfirex A other qusetion : IDXGIAdapter obj how to create ? Link to comment Share on other sites More sharing options...
haijie1223 Posted April 14, 2018 Author Share Posted April 14, 2018 @Danyfirex My question comes from the following code, I want to translate this C++ code。 expandcollapse popup#include "stdafx.h" #include <Windows.h> #include <string.h> #include <dxgi.h> #include <assert.h> void EnumerateUsingDXGI(IDXGIFactory* pDXGIFactory) { assert(pDXGIFactory != 0); for (UINT index = 0; ; ++index) { IDXGIAdapter* pAdapter = nullptr; HRESULT hr = pDXGIFactory->EnumAdapters(index, &pAdapter); if (FAILED(hr)) // DXGIERR_NOT_FOUND is expected when the end of the list is hit break; DXGI_ADAPTER_DESC desc; memset(&desc, 0, sizeof(DXGI_ADAPTER_DESC)); if (SUCCEEDED(pAdapter->GetDesc(&desc))) { wprintf(L"Adapter: [%u] %s\n", index, desc.Description); for (UINT iOutput = 0; ; ++iOutput) { IDXGIOutput* pOutput = nullptr; hr = pAdapter->EnumOutputs(iOutput, &pOutput); if (FAILED(hr)) // DXGIERR_NOT_FOUND is expected when the end of the list is hit break; DXGI_OUTPUT_DESC outputDesc; memset(&outputDesc, 0, sizeof(DXGI_OUTPUT_DESC)); if (SUCCEEDED(pOutput->GetDesc(&outputDesc))) { //wprintf( L"hMonitor: 0x%0.8Ix\n", ( DWORD_PTR )outputDesc.Monitor ); //wprintf( L"hMonitor Device Name: %s\n", outputDesc.DeviceName ); } pOutput->Release(); } printf("Dedicated Video Memory: %Iu MB\n" "Dedicated System Memory: %Iu MB\n" "Shared System Memory: %Iu MB\n", desc.DedicatedVideoMemory / 1024 / 1024, /*desc.DedicatedVideoMemory,*/ desc.DedicatedSystemMemory / 1024 / 1024, /*desc.DedicatedSystemMemory,*/ desc.SharedSystemMemory / 1024 / 1024/*, desc.SharedSystemMemory */); } pAdapter->Release(); } } int main(int argc, char* argv[]) { HINSTANCE hDXGI = LoadLibrary(L"dxgi.dll"); typedef HRESULT(WINAPI* LPCREATEDXGIFACTORY)(REFIID, void**); LPCREATEDXGIFACTORY pCreateDXGIFactory = nullptr; IDXGIFactory* pDXGIFactory = nullptr; // We prefer the use of DXGI 1.1 pCreateDXGIFactory = (LPCREATEDXGIFACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory1"); if (!pCreateDXGIFactory) { pCreateDXGIFactory = (LPCREATEDXGIFACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory"); if (!pCreateDXGIFactory) { FreeLibrary(hDXGI); wprintf(L"ERROR: dxgi.dll missing entry-point\n"); return -1; } } HRESULT hr = pCreateDXGIFactory(__uuidof(IDXGIFactory), (LPVOID*)&pDXGIFactory); if (SUCCEEDED(hr)) { EnumerateUsingDXGI(pDXGIFactory); pDXGIFactory->Release(); return 0; } FreeLibrary(hDXGI); return 0; } Link to comment Share on other sites More sharing options...
Danyfirex Posted April 14, 2018 Share Posted April 14, 2018 as far I can see. You would need to create a pointer to a IDXGIAdapter then casting using Autoit ObjectCreateInterface. I don't have time to traslate that code right now but maybe I'll do later. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danyfirex Posted April 14, 2018 Share Posted April 14, 2018 Here is the whole example in AutoIt. expandcollapse popup;~ #AutoIt3Wrapper_UseX64=y #include <WinAPI.au3> Global Const $DXGI_ERROR_NOT_FOUND = 0x887A0002 Global Const $sTag_DummyIDXGIObject = "Dummy1 hresult();Dummy2 hresult();Dummy3 hresult();Dummy4 hresult();" Global Const $sTag_IDXGIFactory = $sTag_DummyIDXGIObject & "EnumAdapters hresult(uint;ptr*); MakeWindowAssociation hresult(hwnd;uint); GetWindowAssociation hresult(hwnd*); CreateSwapChain hresult(ptr;ptr;ptr*); CreateSoftwareAdapter hresult(hwnd;ptr*);" Global Const $sIID_IDXGIFactory = "{7b7166ec-21c7-44ae-b21a-c9ae321ae369}" Global Const $sTag__IDXGIAdapter = $sTag_DummyIDXGIObject & "EnumOutputs hresult(uint;ptr*);GetDesc hresult(ptr);CheckInterfaceSupport hresult(ptr;long)" Global Const $sIID_IDXGIAdapter = "{2411e7e1-12ac-4ccf-bd14-9798e8534dc0}" Global Const $sTag_DXGI_ADAPTER_DESC = "wchar Description[128];uint VendorId;uint DeviceId;uint SubSysId;uint Revision;ULONG_PTR DedicatedVideoMemory;ULONG_PTR DedicatedSystemMemory;ULONG_PTR SharedSystemMemory;DWORD LowPart;LONG HighPart;" DllOpen("DXGI.dll") Local $tRIID_IDXGIFactory = _WinAPI_CLSIDFromString($sIID_IDXGIFactory) Local $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory1", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0) If @error Or UBound($aRet) <> 3 Then $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0) If @error Or UBound($aRet) <> 3 Then Exit ConsoleWrite("Unable to get IDXGIFactory Interface Pointer" & @CRLF) EndIf EndIf Local $pIDXGIFactory = $aRet[2] ConsoleWrite("$pIDXGIFactory: " & $pIDXGIFactory & @CRLF) If Not $pIDXGIFactory Then Exit ConsoleWrite("Unable to get IDXGIFactory Interface Pointer" & @CRLF) Local $oDXGIFactory = ObjCreateInterface($pIDXGIFactory, $sIID_IDXGIFactory, $sTag_IDXGIFactory) ConsoleWrite("IsObj($oDXGIFactory): " & IsObj($oDXGIFactory) & @CRLF) Local $pAdapter = 0 Local $oAdapter = 0 Local $i = 0 Local $tApdaterDescription = 0 While Not $oDXGIFactory.EnumAdapters($i, $pAdapter) = $DXGI_ERROR_NOT_FOUND ConsoleWrite("$pAdapter: " & $pAdapter & @CRLF) $oAdapter = ObjCreateInterface($pAdapter, $sIID_IDXGIAdapter, $sTag__IDXGIAdapter) ConsoleWrite("IsObj($oAdapter): " & IsObj($oAdapter) & @CRLF) If IsObj($oAdapter) Then $tApdaterDescription = DllStructCreate($sTag_DXGI_ADAPTER_DESC) $oAdapter.GetDesc(DllStructGetPtr($tApdaterDescription)) ConsoleWrite(">>>>>>>>>>>Adapter Information<<<<<<<<<<<<<" & @CRLF) ConsoleWrite("Description: " & $tApdaterDescription.Description & @CRLF) ConsoleWrite("VendorId: " & $tApdaterDescription.VendorId & @CRLF) ConsoleWrite("DeviceId: " & $tApdaterDescription.DeviceId & @CRLF) ConsoleWrite("SubSysId: " & $tApdaterDescription.SubSysId & @CRLF) ConsoleWrite("Revision: " & $tApdaterDescription.Revision & @CRLF) ConsoleWrite("DedicatedVideoMemory: " & $tApdaterDescription.DedicatedVideoMemory & @CRLF) ConsoleWrite("DedicatedSystemMemory: " & $tApdaterDescription.DedicatedSystemMemory & @CRLF) ConsoleWrite("SharedSystemMemory: " & $tApdaterDescription.SharedSystemMemory & @CRLF) ConsoleWrite(@CRLF & @CRLF) $oAdapter = 0 EndIf $i += 1 WEnd Func _WinAPI_CLSIDFromString($sGUID) Local $tGUID = DllStructCreate('ulong Data1;ushort Data2;ushort Data3;byte Data4[8]') Local $iRet = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $sGUID, 'ptr', DllStructGetPtr($tGUID)) If (@error) Or ($iRet[0]) Then Return SetError(@error, @extended, 0) EndIf Return $tGUID EndFunc ;==>_WinAPI_CLSIDFromString Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
haijie1223 Posted April 14, 2018 Author Share Posted April 14, 2018 @Danyfirex thank you very much! I'm here at 11 o'clock in the evening. I'm sick tonight.I will test the code tomorrow. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now