Access Violate Writing Exception Using Python Ctypes on VB6-Based DLL

0

This might seem redundant or very simple to ask but I could not figure out this reading similar posts. Hope its a fixable issue.

I have a WINDLL created based on vb6 code which containes 3 public functions as below:

PrintTitlesName(MyPath as String)
CreateDllFile(MyPath as String)

The description of these two functions are as below:

PrintTitlesName: print titles of the variables that you need to use in the project folder (MyPath) with extension (.MyTitles).
CreatDllFile: Create a file in the project folder (MyPath) with extension (.DLLFile).

Acording to what I read about CTypes, I came up with following code to use the DLL:

import ctypes
NNDLL = ctypes.WinDLL ("D:/ISI/tmp/NN DLL/NNetApply.dll")

# ------------------------------------------------------
#            PrintTitlesName  (MyAddress As String)
# ------------------------------------------------------
TitlesApiProto = ctypes.WINFUNCTYPE (ctypes.c_void_p, ctypes.c_char_p)
TitlesApiParams = (1, "p1", 0),
TitlesApi = TitlesApiProto (("PrintTitlesName", NNDLL), TitlesApiParams)

# ------------------------------------------------------
#          Call Functions
# ------------------------------------------------------
p1 = ctypes.c_char_p ("D:/ISI/tmp/NN DLL/Demo/")
TitlesApi (p1)

Running the code above, leads to Windows Error which seems to be some illegal operation by DLL. However, I cannot put my finger on what is wrong and I would appreciate any help.

Traceback (most recent call last):
  File "D:\ISI\tmp\NN DLL\Test DLL.py", line 98, in <module>
    TitlesApi (p1)
WindowsError: exception: access violation writing 0x00000050
python
exception
dll
ctypes
asked on Stack Overflow Jun 19, 2014 by Moe • edited Jun 19, 2014 by Moe

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0