Solved

need help calling an external function within c#

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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