Solved

need help calling an external function within c#

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chat Room 1 43
C# TextBox 11 30
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 31
How useful is the free version of Selenium? 3 16
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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 hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

25 Experts available now in Live!

Get 1:1 Help Now