Solved

need help calling an external function within c#

Posted on 2016-09-29
1
38 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
About delegates in c sharp 3 47
What is "public object" in C#? 3 45
C# Comparing String Arrays. 5 39
Hey!!!! 1 20
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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