Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:37:53+00:00 2026-06-08T04:37:53+00:00

I am trying to import and use a function from a DLL using Pythons

  • 0

I am trying to import and use a function from a DLL using Pythons ctypes module, but I keep getting this error:

Windows Error: exception: access violation writing 0x0000002C

I’ve had a look at the other questions on similar topics on here, but none seem to be able to provide an answer that works.
My current code is as follows:

from ctypes import *

dll = "./WinlicenseSDK/WinlicenseSDK.dll"

mydll = cdll.LoadLibrary(dll)

name = c_char_p("A.N. Body")
org = c_char_p("ACME")
pcID = c_char_p("APC44567")
zero = c_int(0)
licenseKey = create_string_buffer("")    

mydll.WLGenLicenseFileKey(HASH, name, org, pcID, zero, zero, zero, zero, zero, licenseKey)

Context: I’m investigating licensing techniques for a piece of software. The above function generates a license key from hashing the parameters.

The last parameter for the WLGenLicenseFileKey is a string buffer that the generated key is written to.

I tried setting the argtypes for the function with mydll.WLGenLicenseFileKey.argtypes = ... but this won’t work as there is not a string buffer ctypes raw type as there is for strings, ints, floats etc.

Can anybody tell me where I am going wrong?

EDIT:

The C/C++ function definition:

int WLGenLicenseFileKeyW(    
wchar_t* pLicenseHash,     
wchar_t* pUserName,     
wchar_t* pOrganization,    
wchar_t* pCustomData,     
wchar_t* pMachineID,   
int NumDays,    
int NumExec,    
SYSTEMTIME* pExpirationDate,     
int CountryId,     
int Runtime,     
int GlobalTime,    
char* pBufferOut    
);

That is all the information that the documentation gives on the function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:37:55+00:00Added an answer on June 8, 2026 at 4:37 am

    The length of your licenseKey buffer is one byte, and you are not passing Unicode strings. I’m not in front of my PC, but I this should be close assuming your parameters are otherwise correct. Make sure to call the W version of the function. You also don’t need to create the exact types as long as they are ints and pointers.

    buffer = create_string_buffer(REQUIRED_BUFSIZE)
    mydll.WLGenLicenseKeyW(u"A.N. Body", u"ACME", u"APC44567", None, None, 0, 0, None, 0, 0, 0, buffer)
    

    If you do want to use argtypes, then this is what you want:

    mydll.WLGenLicenseKeyW.argtypes = [c_wchar_t,c_wchar_t,c_wchar_t,c_wchar_t,c_wchar_t,c_int,c_int,c_void_p,c_int,c_int,c_int,c_char_p]
    

    SYSTEMTIME would also need to be defined if you want to pass something besides NULL.

    edit

    I found some documentation. The function uses the stdcall calling convention, so use:

    mydll = WinDLL(dll)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Python 2.5. I'm trying to use this 'with' statement. from __future__ import
I am trying to use a dll in Python source using the ctypes. I
I have a problem where I'm trying to use a function from another module
Trying to access an old c++ dll from c# using Dll Import. Been searching
I am trying to import the MoPub sdk into eclipse, but I am getting
I am trying to use the call function from the Python library inside a
I'm trying to redo the Misaka module in ctypes, but when I try to
I'm trying to restore a database from an sql file through phpmyadmin import function.
Hey guys i'm trying to use drawString() function to draw the result from a
I am receiving this error when trying to use Python Server Pages with Mod_Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.