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

  • Home
  • SEARCH
  • 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 8752415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:13:55+00:00 2026-06-13T13:13:55+00:00

I am to create a python script that will access a windows dll function.

  • 0

I am to create a python script that will access a windows dll function. I was successful in accessing the dll and its functions. Now that, I have a c function as

FIOSCR331_API int FIOCreateDeviceInfoList (PDEVINFO pDevInfoSet)

the problem is the PDEVINFO structure. I must create a structure in python and access this structure.

The C structure is as follows

typedef struct tagDEVINFO
{

    char                    szDeviceName[MAX_PATH];
    char                    szPCSCName[MAX_PATH];
    BOOL                    bPassedFilter;
    BOOL                    bUpdatePassed;
    DWORD                   dwUpdateOrder;
    DWORD                   dwPnP_ID;
    DWORD                   dwFWVersion;
    PDEVEXTENSION   pDevExtension;

} DEVINFO, *PDEVINFO;

the C function is as follows

FIOSCR331_API int FIOCreateDeviceInfoList (PDEVINFO pDevInfoSet)
{

    int nFIOStatus;
    do
    {
            if ( NULL == pDevInfoSet )
            {
                printf("this is inside C code\n");
                    nFIOStatus = IDS_GENERIC_ERROR; //(200)
                    break;
            }
            else
                printf ("\n%s ",pDevInfoSet->szPCSCName);

    }while(false);
}

Now the Python code I implemented

class DEVINFO(Structure):
    _fields_ = [("szDeviceName",c_char_p),
                ("szPCSCName",c_char_p),
                ("bPassedFilter",c_bool),
                ("bUpdatePassed",c_bool),
                ("dwUpdateOrder",c_ulong),
                ("dwPnp_ID",c_ulong),
                ("dwFWVersion",c_ulong),
                ("pDevExtention",DEVEXTENSION)]

lib = cdll.LoadLibrary('libFIOXXXXX.dll')
print (lib)
devInfo = DEVINFO()
devInfo.szPCSCName = c_char_p(b"this is test")
if devInfo is None:
    print("hi")
else:
    print("britto")
funcCreateList = lib.FIOCreateDeviceInfoList(devInfo)
print (funcCreateList)

The Result I got is

britto
this is inside C code
200

The problem is the code goes into NULL condition always, i.e. devInfo is NULL. Why is that?

NEWLY ADDED

In the above python Structure DEVINFO, It contains another structure DEVEXTENSION. How will i be able to access the members of the DEVEXTENSION error??

print (devInfo.pDevExtension.szName)

This throws:

AttributeError: 'LP_DEVEXTENSION" object has no attribute szName
  • 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-13T13:13:56+00:00Added an answer on June 13, 2026 at 1:13 pm

    Your structure declaration is wrong. It should be:

    class DEVINFO(Structure):
        _fields_ = [
            ("szDeviceName", c_char*wintypes.MAX_PATH),
            ("szPCSCName", c_char*wintypes.MAX_PATH),
            ("bPassedFilter", wintypes.BOOL),
            ("bUpdatePassed", wintypes.BOOL),
            ("dwUpdateOrder", wintypes.DWORD),
            ("dwPnp_ID", wintypes.DWORD),
            ("dwFWVersion", wintypes.DWORD),
            ("pDevExtension", POINTER(DEVEXTENSION))
        ]
    

    You must also pass a pointer to the DEVINFO struct when you call FIOCreateDeviceInfoList(). I’d do it like this:

    funcCreateList = lib.FIOCreateDeviceInfoList(byref(devInfo))
    

    As @eryksun helpfully points out, adding

    lib.FIOCreateDeviceInfoList.argtypes = [POINTER(DEVINFO)]
    

    before the call to FIOCreateDeviceInfoList() will make ctypes perform runtime type checking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say a have program.exe , i will create a python script that will
I have a python script that is trying to create a directory tree dynamically
I'm working to create a simple Python script that will ultimately tell you how
I have been given a task to create a Python file that will take
I have a python script that will take each file in a directory, iterate
I'm trying to write a Makefile for a python script, that will create a
I'm trying to create a python script that will allow me to load up
How can I create a simple BAT file that will run my python script
I have a python modules question: I need to write a script that will
I'm currently trying to create a Python script that will autogenerate space-delimited arithmetic expressions

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.