15,910,358 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Mohanraj Sam (Top 16 by date)
Mohanraj Sam
25-Mar-11 9:10am
View
Hi Jones,
I have one doubt, in your program you have written the word "hello". What are the pins in the connector will goes to high or how can I make the particular data pin to high or low. Please clear my doubt.
Thanks & Regards
Mohan
Mohanraj Sam
25-Mar-11 6:48am
View
Hi Jones,
Thanks for your prompt reply.
Mohan
Mohanraj Sam
23-Feb-11 7:06am
View
Hi Laxmikant,
Thank for your immediate reply. Using Int 21/AH=40h seems assembler code, I want to do in C language how can I implement interrupt related code in C. And also another doubt will it make pen drive to write protect.
Please help me
Thanks & Regards
Mohan
Mohanraj Sam
9-Feb-11 5:31am
View
Hi Sandeep,
Thanks for your reply. I'm doing a project with pen drive. In pen drive i need to store some confidential data, so I need to creat a partition which is read only. In that partition only user can read the data and can't write on it. It is better if i make the entire pen drive memory as read only without creating partition.
Thanks in Advance.
Regards
Mohan
Mohanraj Sam
12-Jan-11 8:12am
View
Thanks for your information John
Mohanraj Sam
12-Jan-11 0:24am
View
Thanks Jones. I unable to read intermediate data in the sector. That is i want to read data starting from the offset OEh in the first sector. I tried with the below code,
startinglogicalsector = 1;
SetFilePointer (hDeviceHandle, (startinglogicalsector*14), NULL, FILE_BEGIN);
ReadFile (hDeviceHandle, buff, 512, &dwBytesRead, NULL);
But I get all the values of first sector starting from 0th offset. How can i read from 0Eh offset of 1st sector.
Also i have another question, 0Eh offset represents "Reserved Sectors". Is it gives total number of reserved sectors count or i can use that offset as reserved space. If it says about the count then how can i know which are the sectors are reserved. Any idea about this.
Regards
Mohan
Mohanraj Sam
11-Jan-11 7:10am
View
Hi Jones,
Thanks for ur reply. Actually I used ReadFile()/WriteFile() for read/write operations. If i need to write values in the reserved sector of FAT32 of offset 0Eh, how shall i mentined this address in the WriteFile() because it gets only the sector number.
Regards
Mohan
Mohanraj Sam
10-Jan-11 7:29am
View
Thanks for your answer.
But API calls or IOCTL call may vary for Windows and Linux, right?
Regards
Mohan
Mohanraj Sam
10-Jan-11 5:39am
View
Thanks. I'ad used what is said in the above link, but i get the error code 50(i.e "The request is not supported.
")when using VWIN32_DIOC_DOS_INT25 for read. Can you guess this error.
Regards
Mohan
Mohanraj Sam
7-Jan-11 9:17am
View
Ok Thanks for your information
Mohanraj Sam
7-Jan-11 8:35am
View
Hi,
Thanks for ur prompt reply. I'm using Windows XP service pack 3. It says that Win CE 3.0 and later, then it should work in XP. Am i right? or any file has to be included. I cant understood What you said to include in the previous post. Can you explain clearly.
Thanks
Mohan
Mohanraj Sam
5-Jan-11 5:09am
View
Hi,
Thanks for ur reply. I had used GetLastError(). It gives error code as 2("The system cannot find the file specified"). I dont know why this error i get because the path i had given is correct. Any suggestion?
Regards
Mohan
Mohanraj Sam
31-Dec-10 1:35am
View
Hi,
Thanks for ur reply. I paste the code here, plz go through it and suggest me if I went wrong.
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#include <io.h>
#include <conio.h>
#include <windows.h>
#include <winioctl.h>
#include <setupapi.h>
#include "hidsdi.h"
int main()
{
HANDLE deviceHandle = INVALID_HANDLE_VALUE;
DWORD index = 1;
HIDD_ATTRIBUTES deviceAttributes;
BOOL matched = FALSE;
DWORD vendorID, productID, versionNumber;
while (!matched && (deviceHandle = connectToUSBDevice (index)) != INVALID_HANDLE_VALUE)
{
if (!HidD_GetAttributes (deviceHandle, &deviceAttributes))
return INVALID_HANDLE_VALUE;
if ((vendorID == 0 || deviceAttributes.VendorID == vendorID) &&
(productID == 0 || deviceAttributes.ProductID == productID) &&
(versionNumber == 0 || deviceAttributes.VersionNumber == versionNumber))
return deviceHandle; /* matched */
CloseHandle (deviceHandle); /* not a match - close and try again */
index++;
}
return INVALID_HANDLE_VALUE;
}
int connectToUSBDevice(DWORD in_dwDeviceIndex)
{
BOOL bDiskFreeSts, bGetPartinfo;
DWORD errStatus;
DWORD BytesReturned;
DWORD result;
HANDLE hDeviceHandle = INVALID_HANDLE_VALUE;
PARTITION_INFORMATION_EX PartitionInfomation; //partition structure
DRIVE_LAYOUT_INFORMATION_EX DriveInformation; //drive layout structure
HDEVINFO hDev;
GUID guid;
SP_DEVICE_INTERFACE_DATA interfaceDev;
PSP_INTERFACE_DEVICE_DETAIL_DATA deviceDetail;
ULONG wSize;
//Get the HID GUID value - used as mask to get list of devices
HidD_GetHidGuid(&guid);
//Get a list of devices matching the criteria (hid interface, present)
hDev = SetupDiGetClassDevs(&guid,
NULL, // Define no enumerator (global)
NULL, // Define no
(DIGCF_PRESENT | // Only Devices present
DIGCF_DEVICEINTERFACE)); // Function class devices.
interfaceDev.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
//Go through the list and get the interface data
result = SetupDiEnumDeviceInterfaces (hDev,NULL, &guid, in_dwDeviceIndex, &interfaceDev);
/* Failed to get a device - possibly the index is larger than the number of devices */
if (result == FALSE)
{
errStatus = GetLastError();
printf("\nError in Opening Device....Error Status = %d",errStatus);
SetupDiDestroyDeviceInfoList(hDev);
return INVALID_HANDLE_VALUE;
}
//Get the details with null values to get the required size of the buffer
SetupDiGetDeviceInterfaceDetail(hDev, &interfaceDev, NULL, 0, &wSize,0);
//Allocate the buffer
deviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)malloc(wSize);
deviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
//Fill the buffer with the device details
if (!SetupDiGetDeviceInterfaceDetail(hDev,&interfaceDev, deviceDetail,\
wSize, &wSize, NULL))
{
SetupDiDestroyDeviceInfoList(hDev);
free (deviceDetail);
return INVALID_HANDLE_VALUE;
}
/*Open file on the device*/
hDeviceHandle = CreateFile(deviceDetail->DevicePath /*dev1*/,
GENERIC_READ/* | GENERIC_WRITE*/,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
0,
NULL); // No template file
if(hDeviceHandle == INVALID_HANDLE_VALUE) // cannot open the drive
{
errStatus = GetLastError();
printf("\nError in Opening Device....Error Status = %d",errStatus);
}
else
{
/*Retrieves extended information for each entry in the partition tables for a disk */
bGetPartinfo= DeviceIoControl(hDeviceHandle, // handle to a partition
IOCTL_DISK_GET_DRIVE_LAYOUT_EX, // dwIoControlCode
NULL, // lpInBuffer
0, // nInBufferSize
&DriveInformation, // output buffer
sizeof(DriveInformation), // size of output buffer
Mohanraj Sam
30-Dec-10 6:47am
View
Hi,
Thanks for ur reply. I am new to MS Visual Studio 2008 can you say where i have to go to add the hid.lib for link input
Regards
Mohan
Mohanraj Sam
30-Dec-10 3:53am
View
Hi Igor,
Thanks for ur reply. I realized that there is no hidsdi.lib. Then i included hid.h to fix these problem, but inside hid.h "usb.h" is included. when i compile i get the error as unable to find usb.h. I unable to find in google, where can i get usb.h?
Regards
Mohan
Mohanraj Sam
29-Dec-10 9:21am
View
Hi Henry,
Thanks for ur reply. My pen drive is not detected as "C" it is "F". I tried to open the file for C drive also. Mistakenly copy that code and send. Sorry it is detected as "F"
char dev1[512]="\\\\.\\F:";
Any suggestion?
Regards
Mohan
Show More