def InitStandalone(): """Init standalone ArcGIS license""" # Set ArcObjects version import comtypes from comtypes.client import GetModule g = comtypes.GUID("{6FCCEDE0-179D-4D12-B586-58C88D26CA78}") GetModule((g, 1, 0)) import comtypes.gen.ArcGISVersionLib as esriVersion import comtypes.gen.esriSystem as esriSystem pVM = NewObj(esriVersion.VersionManager, esriVersion.IArcGISVersion) ### CHANGE PATH!!! if not pVM.LoadVersion( esriVersion.esriArcGISDesktop, "10.4"): # arcpy.GetInstallInfo()['Version']): #"10.7"): return False # Get license pInit = NewObj(esriSystem.AoInitialize, esriSystem.IAoInitialize) ProductList = [esriSystem.esriLicenseProductCodeAdvanced, \ esriSystem.esriLicenseProductCodeStandard, \ esriSystem.esriLicenseProductCodeBasic] for eProduct in ProductList: licenseStatus = pInit.IsProductCodeAvailable(eProduct) if licenseStatus != esriSystem.esriLicenseAvailable: continue licenseStatus = pInit.Initialize(eProduct) return (licenseStatus == esriSystem.esriLicenseCheckedOut) return False
class ID3D11Resource(ID3D11DeviceChild): _iid_ = comtypes.GUID("{dc8e63f3-d12b-4952-b47b-5e45026a862d}") _methods_ = [ comtypes.STDMETHOD(None, "GetType"), comtypes.STDMETHOD(None, "SetEvictionPriority"), comtypes.STDMETHOD(wintypes.UINT, "GetEvictionPriority"), ]
def InitStandalone(): """Init standalone ArcGIS license""" # Set ArcObjects version import comtypes from comtypes.client import GetModule g = comtypes.GUID("{6FCCEDE0-179D-4D12-B586-58C88D26CA78}") GetModule((g, 1, 0)) import comtypes.gen.ArcGISVersionLib as esriVersion import comtypes.gen.esriSystem as esriSystem pVM = NewObj(esriVersion.VersionManager, esriVersion.IArcGISVersion) # These needs to be the latest version of ArcGIS if not pVM.LoadVersion(esriVersion.esriArcGISDesktop, "10.5.1"): return False # Get license pInit = NewObj(esriSystem.AoInitialize, esriSystem.IAoInitialize) ProductList = [esriSystem.esriLicenseProductCodeArcInfo, \ esriSystem.esriLicenseProductCodeArcEditor, \ esriSystem.esriLicenseProductCodeArcView] for eProduct in ProductList: licenseStatus = pInit.IsProductCodeAvailable(eProduct) if licenseStatus != esriSystem.esriLicenseAvailable: continue licenseStatus = pInit.Initialize(eProduct) return (licenseStatus == esriSystem.esriLicenseCheckedOut) return False
class IVdsVolume(comtypes.IUnknown): _iid_ = comtypes.GUID("{88306bb2-e71f-478c-86a2-79da200a0f11}") _methods_ = [ comtypes.COMMETHOD( [], comtypes.HRESULT, 'GetProperties', (['out'], ctypes.POINTER(VDS_VOLUME_PROP), 'pVolumeProperties')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'GetPack', (['out'], ctypes.POINTER(ctypes.POINTER(IVdsPack)), 'ppPack')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryPlexes', (['out'], ctypes.POINTER( ctypes.POINTER(IEnumVdsObject)), 'ppEnum')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'Extend', (['in'], ctypes.POINTER(VDS_INPUT_DISK), 'pInputDiskArray'), (['in'], wintypes.LONG, 'lNumberOfDisks'), (['out'], ctypes.POINTER(ctypes.POINTER(IVdsAsync)), 'ppAsync'), ), comtypes.COMMETHOD( [], comtypes.HRESULT, 'Shrink', (['in'], wintypes.ULARGE_INTEGER, 'ullNumberOfBytesToRemove'), (['out'], ctypes.POINTER(ctypes.POINTER(IVdsAsync)), 'ppAsync')), ]
class IDXGIObject(comtypes.IUnknown): _iid_ = comtypes.GUID("{aec22fb8-76f3-4639-9be0-28eb43a67a2e}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateDataInterface"), comtypes.STDMETHOD(comtypes.HRESULT, "GetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "GetParent"), ]
class IDXGIResource(IDXGIDeviceSubObject): _iid_ = comtypes.GUID("{035f3ab4-482e-4e50-b41f-8a7f8bd8960b}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "GetSharedHandle"), comtypes.STDMETHOD(comtypes.HRESULT, "GetUsage"), comtypes.STDMETHOD(comtypes.HRESULT, "SetEvictionPriority"), comtypes.STDMETHOD(comtypes.HRESULT, "GetEvictionPriority"), ]
class ID3D11DeviceChild(comtypes.IUnknown): _iid_ = comtypes.GUID("{1841e5c8-16b0-489b-bcc8-44cfb0d5deae}") _methods_ = [ comtypes.STDMETHOD(None, "GetDevice"), comtypes.STDMETHOD(comtypes.HRESULT, "GetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateDataInterface"), ]
class IDXGISurface(IDXGIDeviceSubObject): _iid_ = comtypes.GUID("{cafcb56c-6ac3-4889-bf47-9e23bbd260ec}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "GetDesc"), comtypes.STDMETHOD(comtypes.HRESULT, "Map", [ctypes.POINTER(DXGI_MAPPED_RECT), wintypes.UINT]), comtypes.STDMETHOD(comtypes.HRESULT, "Unmap"), ]
class IDXGIFactory1(IDXGIFactory): _iid_ = comtypes.GUID("{770aae78-f26f-4dba-a829-253c83d1b387}") _methods_ = [ comtypes.STDMETHOD( comtypes.HRESULT, "EnumAdapters1", [ctypes.c_uint, ctypes.POINTER(ctypes.POINTER(IDXGIAdapter1))]), comtypes.STDMETHOD(wintypes.BOOL, "IsCurrent"), ]
class IDXGIFactory(IDXGIObject): _iid_ = comtypes.GUID("{7b7166ec-21c7-44ae-b21a-c9ae321ae369}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "EnumAdapters"), comtypes.STDMETHOD(comtypes.HRESULT, "MakeWindowAssociation"), comtypes.STDMETHOD(comtypes.HRESULT, "GetWindowAssociation"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateSwapChain"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateSoftwareAdapter"), ]
class EApplication(IDispatch): _iid_=comtypes.GUID('{914934C2-5A91-11CF-8700-00AA0060263B}') _methods_=[] _disp_methods_=[ comtypes.DISPMETHOD([comtypes.dispid(2001)],None,"WindowSelectionChange", (['in'],ctypes.POINTER(IDispatch),'sel'),), comtypes.DISPMETHOD([comtypes.dispid(2013)],None,"SlideShowNextSlide", (['in'],ctypes.POINTER(IDispatch),'slideShowWindow'),), ]
class IVdsSwProvider(comtypes.IUnknown): _iid_ = comtypes.GUID("{9aa58360-ce33-4f92-b658-ed24b14425b8}") _methods_ = [ comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryPacks', (['out'], ctypes.POINTER( ctypes.POINTER(IEnumVdsObject)), 'ppEnum')) ]
class ID3D11Device(comtypes.IUnknown): _iid_ = comtypes.GUID("{db6f6ddb-ac77-4e88-8253-819df9bbf140}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "CreateBuffer"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateTexture1D"), comtypes.STDMETHOD( comtypes.HRESULT, "CreateTexture2D", [ ctypes.POINTER(D3D11_TEXTURE2D_DESC), ctypes.POINTER(None), ctypes.POINTER(ctypes.POINTER(ID3D11Texture2D)), ], ), comtypes.STDMETHOD(comtypes.HRESULT, "CreateTexture3D"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateShaderResourceView"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateUnorderedAccessView"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateRenderTargetView"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateDepthStencilView"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateInputLayout"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateVertexShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateGeometryShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateGeometryShaderWithStreamOutput"), comtypes.STDMETHOD(comtypes.HRESULT, "CreatePixelShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateHullShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateDomainShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateComputeShader"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateClassLinkage"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateBlendState"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateDepthStencilState"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateRasterizerState"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateSamplerState"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateQuery"), comtypes.STDMETHOD(comtypes.HRESULT, "CreatePredicate"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateCounter"), comtypes.STDMETHOD(comtypes.HRESULT, "CreateDeferredContext"), comtypes.STDMETHOD(comtypes.HRESULT, "OpenSharedResource"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckFormatSupport"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckMultisampleQualityLevels"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckCounterInfo"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckCounter"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckFeatureSupport"), comtypes.STDMETHOD(comtypes.HRESULT, "GetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateData"), comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateDataInterface"), comtypes.STDMETHOD(ctypes.c_int32, "GetFeatureLevel"), comtypes.STDMETHOD(ctypes.c_uint, "GetCreationFlags"), comtypes.STDMETHOD(comtypes.HRESULT, "GetDeviceRemovedReason"), comtypes.STDMETHOD( None, "GetImmediateContext", [ctypes.POINTER(ctypes.POINTER(ID3D11DeviceContext))], ), comtypes.STDMETHOD(comtypes.HRESULT, "SetExceptionMode"), comtypes.STDMETHOD(ctypes.c_uint, "GetExceptionMode"), ]
class IVdsServiceLoader(comtypes.IUnknown): _iid_ = comtypes.GUID("{e0393303-90d4-4a97-ab71-e9b671ee2729}") _methods_ = [ comtypes.COMMETHOD([], comtypes.HRESULT, 'LoadService', (['in'], wintypes.LPCWSTR, 'pwszMachineName'), (['out'], ctypes.POINTER( ctypes.POINTER(IVdsService)), 'ppService')) ]
class IEnumVdsObject(comtypes.IUnknown): _iid_ = comtypes.GUID("{118610b7-8d94-4030-b5b8-500889788e4e}") _methods_ = [ comtypes.COMMETHOD( [], comtypes.HRESULT, 'Next', (['in'], wintypes.ULONG, 'celt'), (['out'], ctypes.POINTER(ctypes.POINTER( comtypes.IUnknown)), 'ppObjectArray'), (['out'], ctypes.POINTER(wintypes.ULONG), 'pcFetched')), ]
def _register_class(self): regcls = getattr(self._cls, "_regcls_", self.regcls) cookie = c_ulong() ptr = self._com_pointers_[comtypes.IUnknown._iid_] clsctx = self._cls._reg_clsctx_ clsctx &= ~comtypes.CLSCTX_INPROC # reset the inproc flags oledll.ole32.CoRegisterClassObject( byref(comtypes.GUID(self._cls._reg_clsid_)), ptr, clsctx, regcls, byref(cookie)) self.cookie = cookie
def __init__(self, target, guid=None): self.target = target if guid is None: guid = comtypes.GUID.create_new() else: try: guid = comtypes.GUID(guid) except WindowsError: guid = comtypes.GUID.create_new() self.guid = str(guid)
class IVdsServiceSAN(comtypes.IUnknown): _iid_ = comtypes.GUID("{fc5d23e8-a88b-41a5-8de0-2d2f73c5a630}") _methods_ = [ comtypes.COMMETHOD([], comtypes.HRESULT, 'GetSANPolicy', (['out'], ctypes.POINTER(wintypes.DWORD), 'pSanPolicy')), comtypes.COMMETHOD([], comtypes.HRESULT, 'SetSANPolicy', (['in'], wintypes.DWORD, 'SanPolicy')), ]
class IDXGIAdapter(IDXGIObject): _iid_ = comtypes.GUID("{2411e7e1-12ac-4ccf-bd14-9798e8534dc0}") _methods_ = [ comtypes.STDMETHOD( comtypes.HRESULT, "EnumOutputs", [wintypes.UINT, ctypes.POINTER(ctypes.POINTER(IDXGIOutput))]), comtypes.STDMETHOD(comtypes.HRESULT, "GetDesc"), comtypes.STDMETHOD(comtypes.HRESULT, "CheckInterfaceSupport"), ]
class ChartEvents(IDispatch): _case_insensitive_ = True _iid_ = comtypes.GUID('{0002440F-0000-0000-C000-000000000046}') _idlflags_ = ['hidden'] _methods_ = [] _disp_methods_=[ comtypes.DISPMETHOD([comtypes.dispid(235)], None, 'Select', ( ['in'], ctypes.c_int, 'ElementID' ), ( ['in'], ctypes.c_int, 'Arg1' ), ( ['in'], ctypes.c_int, 'Arg2' )), ]
class IDXGIOutput1(IDXGIOutput): _iid_ = comtypes.GUID("{00cddea8-939b-4b83-a340-a685226666cc}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "GetDisplayModeList1"), comtypes.STDMETHOD(comtypes.HRESULT, "FindClosestMatchingMode1"), comtypes.STDMETHOD(comtypes.HRESULT, "GetDisplaySurfaceData1"), comtypes.STDMETHOD(comtypes.HRESULT, "DuplicateOutput", [ ctypes.POINTER(ID3D11Device), ctypes.POINTER(ctypes.POINTER(IDXGIOutputDuplication)) ]), ]
class IDXGIResource1(IDXGIResource): _iid_ = comtypes.GUID("{30961379-4609-4a41-998e-54fe567ee0c1}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "CreateSharedHandle", [ ctypes.POINTER(SECURITY_ATTRIBUTES), wintypes.DWORD, wintypes.LPCWSTR, ctypes.POINTER(wintypes.HANDLE), ]), comtypes.STDMETHOD(comtypes.HRESULT, "CreateSubresourceSurface"), ]
class IVdsService(comtypes.IUnknown): _iid_ = comtypes.GUID("{0818a8ef-9ba9-40d8-a6f9-e22833cc771e}") _methods_ = [ comtypes.COMMETHOD([], comtypes.HRESULT, 'IsServiceReady'), comtypes.COMMETHOD([], comtypes.HRESULT, 'WaitForServiceReady'), comtypes.COMMETHOD([], comtypes.HRESULT, 'GetProperties', (['out'], ctypes.c_void_p, 'pServiceProp')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryProviders', (['in'], wintypes.DWORD, 'masks'), (['out'], ctypes.POINTER( ctypes.POINTER(IEnumVdsObject)), 'ppEnum')) ]
class IVdsAsync(comtypes.IUnknown): _iid_ = comtypes.GUID("{d5d23b6d-5a55-4492-9889-397a3c2d2dbc}") _methods_ = [ comtypes.COMMETHOD([], comtypes.HRESULT, 'Cancel'), comtypes.COMMETHOD( [], comtypes.HRESULT, 'Wait', (['out'], ctypes.POINTER(ctypes.HRESULT), 'pHrResult'), (['out'], ctypes.POINTER(VDS_ASYNC_OUTPUT), 'pAsyncOut')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryStatus', (['out'], ctypes.POINTER(ctypes.HRESULT), 'pHrResult'), (['out'], ctypes.POINTER(wintypes.ULONG), 'pulPercentCompleted')), ]
class IDXGIOutputDuplication(IDXGIObject): _iid_ = comtypes.GUID("{191cfac3-a341-470d-b26e-a864f428319c}") _methods_ = [ comtypes.STDMETHOD(None, "GetDesc"), comtypes.STDMETHOD(comtypes.HRESULT, "AcquireNextFrame", [ wintypes.UINT, ctypes.POINTER(DXGI_OUTDUPL_FRAME_INFO), ctypes.POINTER(ctypes.POINTER(IDXGIResource)) ]), comtypes.STDMETHOD(comtypes.HRESULT, "GetFrameDirtyRects"), comtypes.STDMETHOD(comtypes.HRESULT, "GetFrameMoveRects"), comtypes.STDMETHOD(comtypes.HRESULT, "GetFramePointerShape"), comtypes.STDMETHOD(comtypes.HRESULT, "MapDesktopSurface"), comtypes.STDMETHOD(comtypes.HRESULT, "UnMapDesktopSurface"), comtypes.STDMETHOD(comtypes.HRESULT, "ReleaseFrame"), ]
class IDXGIOutput(IDXGIObject): _iid_ = comtypes.GUID("{ae02eedb-c735-4690-8d52-5a8dc20213aa}") _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "GetDesc", [ctypes.POINTER(DXGI_OUTPUT_DESC)]), comtypes.STDMETHOD(comtypes.HRESULT, "GetDisplayModeList"), comtypes.STDMETHOD(comtypes.HRESULT, "FindClosestMatchingMode"), comtypes.STDMETHOD(comtypes.HRESULT, "WaitForVBlank"), comtypes.STDMETHOD(comtypes.HRESULT, "TakeOwnership"), comtypes.STDMETHOD(None, "ReleaseOwnership"), comtypes.STDMETHOD(comtypes.HRESULT, "GetGammaControlCapabilities"), comtypes.STDMETHOD(comtypes.HRESULT, "SetGammaControl"), comtypes.STDMETHOD(comtypes.HRESULT, "GetGammaControl"), comtypes.STDMETHOD(comtypes.HRESULT, "SetDisplaySurface"), comtypes.STDMETHOD(comtypes.HRESULT, "GetDisplaySurfaceData"), comtypes.STDMETHOD(comtypes.HRESULT, "GetFrameStatistics"), ]
def __init__(self, parent, args): self.parent = parent self.args = args self.terminate = False container = ctypes.POINTER(comtypes.IUnknown)() control = ctypes.POINTER(comtypes.IUnknown)() guid = comtypes.GUID() sink = ctypes.POINTER(comtypes.IUnknown)() ctypes.windll.atl.AtlAxCreateControlEx('YUANTAQUOTE.YuantaQuoteCtrl.1', self.parent.Handle, None, ctypes.byref(container), ctypes.byref(control), ctypes.byref(guid), sink) self.ctrl = comtypes.client.GetBestInterface(control) self.sink = comtypes.client.GetEvents(self.ctrl, self) self.update_savedir()
class IVdsDisk(comtypes.IUnknown): _iid_ = comtypes.GUID("{07e5c822-f00c-47a1-8fce-b244da56fd06}") _methods_ = [ comtypes.COMMETHOD( [], comtypes.HRESULT, 'GetProperties', (['out'], ctypes.POINTER(VDS_DISK_PROP), 'pDiskProperties')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'GetPack', (['out'], ctypes.POINTER(ctypes.POINTER(IVdsPack)), 'ppPack')), comtypes.COMMETHOD([], comtypes.HRESULT, 'GetIdentificationData', (['out'], ctypes.c_void_p, 'pLunInfo')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryExtents', (['out'], ctypes.POINTER( ctypes.POINTER(VDS_DISK_EXTENT)), 'ppExtentArray'), (['out'], ctypes.POINTER(wintypes.LONG), 'plNumberOfExtents')), ]
class IVdsPack(comtypes.IUnknown): _iid_ = comtypes.GUID("{3b69d7f5-9d94-4648-91ca-79939ba263bf}") _methods_ = [ comtypes.COMMETHOD([], comtypes.HRESULT, 'GetProperties', (['out'], ctypes.c_void_p, 'pPackProp')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'GetProvider', (['out'], ctypes.POINTER(ctypes.POINTER( comtypes.IUnknown)), 'ppProvider')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryVolumes', (['out'], ctypes.POINTER( ctypes.POINTER(IEnumVdsObject)), 'ppEnum')), comtypes.COMMETHOD( [], comtypes.HRESULT, 'QueryDisks', (['out'], ctypes.POINTER( ctypes.POINTER(IEnumVdsObject)), 'ppEnum')) ]
def SHGetKnownFolderPath(folderGuid: Union[FolderId, str], dwFlags: int = 0, hToken: Optional[int] = None) -> str: """Wrapper for `SHGetKnownFolderPath` which caches the results to avoid calling the win32 function unnecessarily.""" if isinstance(folderGuid, FolderId): folderGuid = folderGuid.value guid = comtypes.GUID(folderGuid) pathPointer = ctypes.c_wchar_p() res = ctypes.windll.shell32.SHGetKnownFolderPath(comtypes.byref(guid), dwFlags, hToken, ctypes.byref(pathPointer)) if res != 0: raise RuntimeError( f"SHGetKnownFolderPath failed with error code {res}") path = pathPointer.value ctypes.windll.ole32.CoTaskMemFree(pathPointer) return path