Solved

need help calling an external function within c#

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now