def LoadResource(hModule, type_, name, language): with pywin32error(): hrsrc = _kernel32._FindResourceEx(hModule, type_, name, language) size = _kernel32._SizeofResource(hModule, hrsrc) hglob = _kernel32._LoadResource(hModule, hrsrc) pointer = _kernel32._LockResource(hglob) return _common._PyBytes_FromStringAndSize(pointer, size)
def LoadResource(hModule, type, name, language=LANG_NEUTRAL): """ Find and Load a resource component. Parameters ---------- handle : hModule The handle of the module containing the resource. Use None for current process executable. type : str : int The type of resource to load. name : str : int The name or Id of the resource to load. language : int Language to use, default is LANG_NEUTRAL. Returns ------- resource : bytes The byte string blob of the resource """ with _pywin32error(): hrsrc = _resource._FindResourceEx(hModule, type, name, language) size = _resource._SizeofResource(hModule, hrsrc) hglob = _resource._LoadResource(hModule, hrsrc) if _backend == 'ctypes': pointer = _common.cast(_resource._LockResource(hglob), _common.c_char_p) else: pointer = _resource._LockResource(hglob) return _common._PyBytes_FromStringAndSize(pointer, size)
def LoadResource(hModule, type, name, language=LANG_NEUTRAL): """ Find and Load a resource component. Parameters ---------- handle : hModule The handle of the module containing the resource. Use None for current process executable. type : str : int The type of resource to load. name : str : int The name or Id of the resource to load. language : int Language to use, default is LANG_NEUTRAL. Returns ------- resource : bytes The byte string blob of the resource """ with _pywin32error(): hrsrc = _resource._FindResourceEx(hModule, type, name, language) size = _resource._SizeofResource(hModule, hrsrc) hglob = _resource._LoadResource(hModule, hrsrc) if _backend == 'ctypes': pointer = _common.cast( _resource._LockResource(hglob), _common.c_char_p) else: pointer = _resource._LockResource(hglob) return _common._PyBytes_FromStringAndSize(pointer, size)
def LoadResource(hModule, type, name, language=LANG_NEUTRAL): """ Find and Load a resource component. Parameters ---------- handle : hModule The handle of the module containing the resource. Use None for current process executable. type : str : int The type of resource to load. name : str : int The name or Id of the resource to load. language : int Language to use, default is LANG_NEUTRAL. Returns ------- resource : bytes The byte string blob of the resource See also -------- - `FindResourceEx MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648043(v=vs.85).aspx>`_ - `SizeofResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648048(v=vs.85).aspx>`_ - `LoadResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648046(v=vs.85).aspx>`_ - `LockResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648047(v=vs.85).aspx>`_ - `Predefined resource types <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648009(v=vs.85).aspx>`_ - `Predefined resource language ids <https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx>`_ """ with _pywin32error(): hrsrc = _kernel32._FindResourceEx(hModule, type, name, language) size = _kernel32._SizeofResource(hModule, hrsrc) hglob = _kernel32._LoadResource(hModule, hrsrc) if _backend == 'ctypes': pointer = _common.cast(_kernel32._LockResource(hglob), _common.c_char_p) else: pointer = _kernel32._LockResource(hglob) return _common._PyBytes_FromStringAndSize(pointer, size)
def CredRead(TargetName, Type): """ Mimic pywin32 win32cred.CreadRead. Parameters ---------- TargetName: str-like The target name to fetch from the keyring. Returns ------- credentials: dict A dictionary containing the following: - UserName: the retrieved username - CredentialBlob: the password (as an utf-16 encoded 'string') None if the target name was not found. """ if not Type == CRED_TYPE_GENERIC: raise ValueError("Type != CRED_TYPE_GENERIC not yet supported") flag = 0 c_pcreds = _advapi32.PCREDENTIAL() with pywin32error(): _advapi32._CredRead(TargetName, Type, flag, ctypes.byref(c_pcreds)) try: c_creds = c_pcreds.contents credential = {} for key in _advapi32.SUPPORTED_CREDKEYS: if key != 'CredentialBlob': credential[key] = getattr(c_creds, key) else: blob = _common._PyBytes_FromStringAndSize( c_creds.CredentialBlob, c_creds.CredentialBlobSize) credential['CredentialBlob'] = blob return credential finally: _advapi32._CredFree(c_pcreds)
def LoadResource(hModule, type, name, language=LANG_NEUTRAL): """ Find and Load a resource component. Parameters ---------- handle : The handle of the module containing the resource. Use None for currrent process executable. type : str : int The type of resource to load. name : The name or Id of the resource to load. language : int Language to use, default is LANG_NEUTRAL. Returns ------- hModule : Handle of the loaded source. See also -------- - `FindResourceEx MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648043(v=vs.85).aspx>`_ - `SizeofResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648048(v=vs.85).aspx>`_ - `LoadResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648046(v=vs.85).aspx>`_ - `LockResource MSDN reference <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648047(v=vs.85).aspx>`_ - `Predefined resource types <https://msdn.microsoft.com/en-us/library/windows/desktop/ms648009(v=vs.85).aspx>`_ - `Predefined resource language ids <https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx>`_ """ with _pywin32error(): hrsrc = _kernel32._FindResourceEx(hModule, type, name, language) size = _kernel32._SizeofResource(hModule, hrsrc) hglob = _kernel32._LoadResource(hModule, hrsrc) pointer = _kernel32._LockResource(hglob) return _common._PyBytes_FromStringAndSize(pointer, size)