Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

need help calling an external function within c#

Posted on 2016-09-29
1
Medium Priority
?
65 Views
Last Modified: 2016-09-29
hi.

regarding MS article:   https://msdn.microsoft.com/en-us/windows/hardware/drivers/install/retrieving-a-device-instance-property-value

i am attempting to call setupDiGetDeviceProperty:

            [DllImport("setupapi.dll", SetLastError = true)]
            static extern bool SetupDiGetDevicePropertyW(
                    IntPtr deviceInfoSet,
                    [In] ref SP_DEVINFO_DATA DeviceInfoData,
                    [In] ref DEVPROPKEY propertyKey,
                    [Out] out UInt32 propertyType,
                    IntPtr propertyBuffer,
                    UInt32 propertyBufferSize,
                    out UInt32 requiredSize,
                    UInt32 flags);

when i call it the first time, the requiredSize is being returned fine.  when i call the function for a second time, i receive error code 1784:
ERROR_INVALID_USER_BUFFER
    1784
    The supplied user buffer is not valid for the requested operation

i'm using this the second time:

SetupDiGetDevicePropertyW(info, ref devdata, ref devprop, out proptype, propertyBuffer, requiredSize, out temp, 0)

i don't know what to send the function for the propertyBuffer.... will you please help?

thank you.
0
Comment
Question by:freezingHot
1 Comment
 
LVL 1

Accepted Solution

by:
freezingHot earned 0 total points
ID: 41822650
ended up using a byte array and it worked...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question