Advertisement
maiconsaraiva

Exemplo - Carregando DLL Delphi no Python

Sep 14th, 2021
1,314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. """
  2. Exemplo de uso da DLL SismaisERPLib no Python
  3. """
  4. import sys
  5. import os
  6. import ctypes
  7.  
  8. def main():
  9.     path = os.path.dirname(os.path.realpath(__file__))
  10.    
  11.     is_64bits = sys.maxsize > 2**32    
  12.     if is_64bits:
  13.         #dll_name = 'D:\\Sismais\\SismaisERPLib\\SismaisERPLibx64.dll'
  14.         dll_name = path + '\SismaisERPLibx64.dll'
  15.     else:
  16.         dll_name = 'D:\\Sismais\\SismaisERPLib\\SismaisERPLibx32.dll'
  17.  
  18.     dll = ctypes.windll.LoadLibrary(dll_name)
  19.  
  20.     funcao = dll.EncryptUserPassword
  21.     funcao.restype = ctypes.c_wchar_p    
  22.     funcao.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p]
  23.     #usuario = ctypes.c_wchar_p('usuario')
  24.     #senha = ctypes.c_wchar_p('senha')    
  25.     #r = funcao(_usuario, _senha)
  26.     r = funcao('usuario', 'senha')
  27.    
  28.     # resultado esperado:
  29.     if r == 'senha_criptografada':
  30.         print('Retorno da função EncryptUserPassword está correto:')
  31.     else:
  32.         print('Retorno da função EncryptUserPassword está ERRADO!')
  33.     print(r)
  34.    
  35.  
  36. if __name__ == '__main__':
  37.     main()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement