hi...can anyone tell me why im getting an IntPtr of -1 being returned? the
device is plugged in and being recognized by windows....so i dont understand
this. Thanks
private void GetFiles(String str)
{
IntPtr ptrHandle;
IntPtr lpData;
short shrtInLength;
short shrtOutLength;
HidCaps oCaps;
try
{
ptrHandle = CreateFile(str, GENERIC_READ | GENERIC_WRITE, 0,
IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
HidD_GetPreparsedData(ptrHandle, out lpData);
HidP_GetCaps(lpData, out oCaps); // extract the device
capabilities from the internal buffer
shrtInLength = oCaps.InputReportByteLength; // get the
input...
shrtOutLength = oCaps.OutputReportByteLength; // ... and
output report lengths
//FileStream fs = new System.IO.FileStream(ptrHandle,
FileAccess.ReadWrite);
}
catch (Exception ex)
{
}
finally
{
HidD_FreePreparsedData(lpData);
}
}
--
-iwdu15 3 2064
iwdu15 wrote:
hi...can anyone tell me why im getting an IntPtr of -1 being returned? the
device is plugged in and being recognized by windows....so i dont understand
this. Thanks
private void GetFiles(String str)
{
IntPtr ptrHandle;
IntPtr lpData;
short shrtInLength;
short shrtOutLength;
HidCaps oCaps;
try
{
ptrHandle = CreateFile(str, GENERIC_READ | GENERIC_WRITE, 0,
IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
HidD_GetPreparsedData(ptrHandle, out lpData);
HidP_GetCaps(lpData, out oCaps); // extract the device
capabilities from the internal buffer
shrtInLength = oCaps.InputReportByteLength; // get the
input...
shrtOutLength = oCaps.OutputReportByteLength; // ... and
output report lengths
//FileStream fs = new System.IO.FileStream(ptrHandle,
FileAccess.ReadWrite);
}
catch (Exception ex)
{
}
finally
{
HidD_FreePreparsedData(lpData);
}
}
--
-iwdu15
Can you show your actual declaration for CreateFile and the constants
your passing to it?
Thanks.
--
Tom Shelton
"iwdu15" <jmmgoalsteratyahoodotcomwrote in message
news:99**********************************@microsof t.com...
| hi...can anyone tell me why im getting an IntPtr of -1 being returned? the
| device is plugged in and being recognized by windows....so i dont
understand
| this. Thanks
|
| private void GetFiles(String str)
| {
|
| IntPtr ptrHandle;
| IntPtr lpData;
|
| short shrtInLength;
| short shrtOutLength;
|
| HidCaps oCaps;
|
| try
| {
|
| ptrHandle = CreateFile(str, GENERIC_READ | GENERIC_WRITE,
0,
| IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
|
| HidD_GetPreparsedData(ptrHandle, out lpData);
|
| HidP_GetCaps(lpData, out oCaps); // extract the device
| capabilities from the internal buffer
|
| shrtInLength = oCaps.InputReportByteLength; // get the
| input...
| shrtOutLength = oCaps.OutputReportByteLength; // ... and
| output report lengths
|
| //FileStream fs = new System.IO.FileStream(ptrHandle,
| FileAccess.ReadWrite);
|
| }
| catch (Exception ex)
| {
|
| }
| finally
| {
|
| HidD_FreePreparsedData(lpData);
|
| }
|
| }
|
| --
| -iwdu15
No we can't, but you can if you call Marshal.GetLastWin32Error after the
failing API call. This will return the windows error code, provided you have
declared your DllImport correctly (mind to post the declaration also??).
Note that you should always call GetLastWin32Error for API's that return
error information after the call.
Willy.
i think i figured it out...which was a big mistake on my part. i was trying
to communicate with my MP3 player, USB Device, using HID APIs....my bad,
thanks though
--
-iwdu15 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacek |
last post by:
Hi
If it is wrong newsgroup, please let me know where to find the answer.
I am trying to get item text form ListView (there are few items and 5
columns) from other application (application written...
|
by: Tedmond |
last post by:
Dear all,
How can I get all the titles of all openning windows? I found a API in
win32 that called EnumWindows() but it returns only the windows handles, not
titles. How can I get the list just...
|
by: Roohi |
last post by:
hi
I am trying to copy an image to a clipboard and then get a
handle to the clipboard using API calls GetClipboardData().
Following is the snippet of our code. Could any one please
point out...
|
by: Rik Hemsley |
last post by:
How does one go about getting a pointer to method as an IntPtr?
Example:
public class A
{
public void X()
{
Y(Z);
}
|
by: Bruce Wood |
last post by:
I'm having a devil of a time calling DeviceCapabilities() in order to
get the list of paper names / codes / sizes for a printer. Here is my
code and the input it produces:
static extern Int32...
| |
by: pangel83 |
last post by:
I've been trying for days to write a piece of VB.NET code that will
read from winamp's memory space the paths of the files from the current
winamp playlist.
The GETPLAYLISTFILE command of the...
|
by: Nathan Sokalski |
last post by:
I would like to be able to get the ContentType of a file programmatically
(for example, I want *.txt files to return "text/plain"). I could not find a
way to do this using VB.NET's classes, but I...
|
by: Mark Rae |
last post by:
Hi,
I have used the code below to return the default printer in 32-bit WinXP
Pro, but now that I am running 64-bit Vista Business I'm getting an error:
using System.Drawing.Printing;
using...
|
by: Sin Jeong-hun |
last post by:
Hello.
Speical folders, like Desktop, usually have different display names.
For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want
to get the this displayed name of a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |