Join also our Discord channel! Click here.

Load DLL with Python - Solved

Coders and would-be coders alike, this is the place to talk about programming.
Post Reply
jayn23
veteran
Posts: 128
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 32 times
Been thanked: 118 times

Load DLL with Python - Solved

Post by jayn23 » Thu Mar 12, 2020 11:48 pm

Hi,

I am currently researching .gr2 format and want to import granny2.dll in order to decompress the files, but i am having issues with implementing it python since every example i have managed to find was written in c++.
any help would be very much appreciated

for loading the DLL i tried 2 approaches using ctypes:
first:

Code: Select all

MyDllObject = ctypes.cdll.LoadLibrary("granny2.dll")
MyFunctionObject = MyDllObject._GrannyDecompressData@32

but this is an instant fail since it reads the function name up to "@" and stops so it never finds the wanted function
second:

Code: Select all

lib = ctypes.WinDLL("granny2.dll")
func = lib['_GrannyDecompressData@32']
value = func(section.compression,0,section.data_size,ComperesedData,section.first16bit,section.first8bit,section.decompressed_size,DecompressedData)
it does seem to find the function, but i am un-share how to send the parameters needed for the decompression, since i keep getting errors no matter what combo i try.


Thanks in advance
Last edited by jayn23 on Fri Mar 13, 2020 3:52 pm, edited 1 time in total.

jayn23
veteran
Posts: 128
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 32 times
Been thanked: 118 times

Re: Load DLL with Python

Post by jayn23 » Fri Mar 13, 2020 3:50 pm

I got it working it seems the syntax for my second try was actually correct the problem was with the parameters i was sending didn't fit what the function was expecting to receive, ill just note for anyone who might wonder here in the future if your sending a bytes object/bytesarray make sure its the correct size or program will crash with a debug error.

Post Reply