|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
reading a sector on USB memory stickHello,
I need to write an VB6 application for reading and writing a sector on a USB memory stick in a Windows XP system. I looked arounf for some sample code but was not succesful in locating anything. Anybody any suggestions? Bu "Bu" <s*@si.si> wrote in message You mean a specific sector? I don't think you can do that with VB. This news:kf5535pb3lelka6hcljuoej5ht58v3svad@4ax.com... > Hello, > I need to write an VB6 application for reading and writing a sector on > a USB memory stick in a Windows XP system. > I looked arounf for some sample code but was not succesful in locating > anything. would require very low-level disk access. Possibly there's such an API function that you could call from VB, but I have doubts. Out of curiosity, would you mind explaining why you need to do this? -- Mike "Bu" <s*@si.si> wrote in message That kind of access is too low-level for VB. You'd have to have some news:kf5535pb3lelka6hcljuoej5ht58v3svad@4ax.com... > I need to write an VB6 application for reading and writing a sector on > a USB memory stick in a Windows XP system. > I looked arounf for some sample code but was not succesful in locating > anything. > Anybody any suggestions? specialized DLL (most likely written in C[++]) which your VB program could utilize. In other words, VB itself is not going to do this. Bu wrote:
> Hello, Windows, at least the NT-variants like 2K / XP etc, allow you to open> I need to write an VB6 application for reading and writing a sector > on a USB memory stick in a Windows XP system. > I looked arounf for some sample code but was not succesful in > locating anything. > Anybody any suggestions? many block devices as though they were files, using CreateFile. Use the syntax \\.\X: (where X is the drive letter) to get access to the block device at the sector level. For example, hDevice = CreateFile("\\.\E:", _ GENERIC_READ Or GENERIC_WRITE, _ FILE_SHARE_READ Or FILE_SHARE_WRITE, _ 0, _ OPEN_EXISTING, _ 0, _ 0) If this succeeds, hDevice can be used with ReadFile to read specific portions of the disk. You may need to first Lock the device to get raw access, and you should only request the access you need -- don't ask for GENERIC_WRITE access if you don't need it. The example shown passes a null SECURITY_DESCRIPTOR, which is another potential point of failure. You may need to explicitly pass a descriptor that allows the user the specific permissions needed. Good luck! On Fri, 12 Jun 2009 19:58:27 +0200, Bu <s*@si.si> wrote:
>Hello, On http://www.vbforums.com/showthread.php?p=3538536#post3538536>I need to write an VB6 application for reading and writing a sector on >a USB memory stick in a Windows XP system. >I looked arounf for some sample code but was not succesful in locating >anything. >Anybody any suggestions? >Bu FYI I got some information that might be of interest to you. Bu |
|||||||||||||||||||||||