WriteFile In USB With VB?

Jan 12, 2012

In VB read HID, we detect the device successfully. When sending a 8 bytes command to the device,

type Reg Value Index Length 40 48 00 00 00 00 01 00

With the OutputReportlength=2, how to set the send buffer in the WriteFile function?

View 13 Replies


ADVERTISEMENT

WriteFile Call Works On X86 But Not X64

Sep 3, 2010

I am using CreateFile, WriteFile and ReadFile API calls to write some data to a USB device. The code I have works perfectly on 32 bit systems. CreateFile gets a handle to the device, pass that handle and some data to WriteFile and read from that handle with ReadFile.My problem is, the same code does not work on a 64 bit system. The error returned from WriteFile is 6, The handle is invalid. I've checked the handle for validity on the CreateFile call and it is a valid handle. A call to LastDLLError() returns 0 after CreateFile.The "file" is being opened for overlapped communication and the overlapped init calls are also returning their proper values.is there some sort of different consideration I need to make because it's a 64 bit system? A different flag? A different call altogether?

View 6 Replies

API WriteFile Protected Memory Access?

May 22, 2009

I'm currently using an unmanaged library written in C++ and imported via <DLLImport()> to access a dos virtual device driver, and that works fine. However, I'd like to be able to do this via my .NET application (without requiring an accompanying DLL). So, I'm trying to write to the virtual dos device using the kernel32 API and WriteFile, however I receive the error: "Attempted to read or write protected memory."

Mapping to the device with DefineDosDevice and CreateFile (also in the kernel32 API) works fine and returns a valid file handle, however when I attempt to write to the file it fails. I've even tried marshaling the data to an unmanaged block of memory using InteropServices (AllocHGlobal and StructureToPtr) and then writing it from there, however I still receive the same error.

View 2 Replies

Displaying Htm Contents In Browser Via Response.Writefile In ASP.Net

Apr 18, 2012

I'm working on a site that I've inherited that's built with ASP.Net, which I'm only slightly familiar with. One of the pages allows for a link to a document (word or pdf) that, when clicked on, prompts the user to save or open the file, but does not reveal the true path of the file. This way it prevents users from pasting a url to a file - the link is to an aspx file that checks for a valid session, and then retrieves the file.

Anyway, because there's a lot of legacy code, I need to do this with a bunch of static htm files as well, however these files need to be displayed rather than prompting the user to save them, which is what happens now. I tried changing the content type to application/text, application/html, text/html, etc. and that didn't work, then tried adding a response header of content-disposition inline. When I do that, build, and try linking to the file, I get a couple of runtime exceptions:

[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.Conversions.ParseDecimal(String Value, NumberFormatInfo NumberFormat) +206
Microsoft.VisualBasic.CompilerServices.Conversions.ToLong(String Value) +110

[Code].....

Do I have to do something with an htmlwriter object or something? Can't I just have it open a new browser window with the file displaying or does it have to prompt the user if used in this way??

View 3 Replies

Set The Buffer (2nd Pramater Declared Below ) In The WriteFile Function?

Jan 16, 2012

[code]...

In VB read HID, we detect the device as above successfully. (STM32L)

When sending a 8 bytes command to the device,

type Reg Value Index Length

40 48 00 00 00 00 01 00

with the nNumberOfBytesToWrite=2 (3rd paramater declared below), how to set the Buffer (2nd pramater declared below ) in the WriteFile function? Size of Buffer is within the limitation of OutputReportByteLength(=nNumberOfBytesToWrite).

[code]...

View 1 Replies

.net - WriteFile Failing Depending On Length Of Data To Write?

Jun 6, 2011

Oddly enough, I've worked around this issue, but it's still annoying me. I worked around it by sending too-long writes, with padded zeroes; the code works but sends a few hundred unnecessary bytes. Specifically, I need to send exactly 992-byte packets instead of 7 or 19-byte packets

View 2 Replies

Return Key Event Make WriteFile For Com Port 0 Bytes Written?

Jan 22, 2010

I have textbox with vbscript, user could type integers, then hit return key, KeyUp event for return would trigge theWriteFile()being called for com port to write string to the device, if Ihit return key slow, I would get 0bytewritten for WriteFile(), timeout happening basically,if I hit return keyquick,

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved