|
i want to access the Card reader that is connect as drive.
|
|
|
|
|
What do you want to do though? Are you trying to write to it? Do you not know what logical drive was assigned to it? Be more specific.
|
|
|
|
|
i just want to read this?and read data of smart card is inserted in it.
|
|
|
|
|
Have you tried ReadFile()?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
it means open it with CreateFile?
what parameter pass here for file name like \\.\driveletter: or anything else.
when i CreateFile using "\\.\driveletter:" and ReadFile than its return 0 and getlasterror is "The Parameter is incorrect".
and when i open it as physicaldrive its give "the device is not ready"
so now waht can i do?
and also tell me how can i diffrentiate this from other drive.
please guide me.
thanks.
modified 5-Mar-12 0:11am.
|
|
|
|
|
Le@rner wrote: what parameter pass here for file name like \\.\driveletter: or anything
else.
See this discussion.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
HDEVINFO hDevInfo, hIntDevInfo;
BOOL disk_status=FALSE;
hDevInfo = SetupDiGetClassDevs(
(LPGUID) &GUID_DEVCLASS_DISKDRIVE,
NULL,
NULL,
DIGCF_PRESENT ); if (hDevInfo == INVALID_HANDLE_VALUE)
{
return 0;
}
hIntDevInfo = SetupDiGetClassDevs (
(LPGUID)&GUID_DEVCLASS_DISKDRIVE,
NULL, NULL, (DIGCF_PRESENT | DIGCF_INTERFACEDEVICE ));
if( hDevInfo == INVALID_HANDLE_VALUE )
{
return 0;
}
SP_DEVICE_INTERFACE_DATA interfaceData;
PSP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData = NULL;
PUCHAR disk_p;
UCHAR outBuf[512];
ULONG length = 0,
returned = 0,
returnedLength=0;
DWORD interfaceDetailDataSize,
reqSize,
errorCode,
disk_i=0;
DWORD Index=0;
interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);
disk_status = SetupDiEnumDeviceInterfaces (
hIntDevInfo, 0, (LPGUID)&GUID_DEVCLASS_DISKDRIVE, Index, &interfaceData );
if ( disk_status == FALSE )
{
errorCode = GetLastError();
if ( errorCode == ERROR_NO_MORE_ITEMS )
{
}
else
{
}
return 0;
}
disk_status = SetupDiGetDeviceInterfaceDetail (
hIntDevInfo, &interfaceData, NULL, 0, &reqSize, NULL );
if ( disk_status == FALSE )
{
errorCode = GetLastError();
if ( errorCode != ERROR_INSUFFICIENT_BUFFER ) {
return 0;
}
}
interfaceDetailDataSize = reqSize;
interfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc (interfaceDetailDataSize);
if ( interfaceDetailData == NULL )
{
return 0;
}
interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA);
disk_status = SetupDiGetDeviceInterfaceDetail (
hIntDevInfo, &interfaceData, interfaceDetailData, interfaceDetailDataSize, &reqSize, NULL);
if ( disk_status == FALSE ) {
return 0;
}
serial_handle = CreateFile(
interfaceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
Open device successfullt, but read file return 0;
success = ReadFile(serial_handle,&rxBuffer,max_rx_size,&read_nbr,NULL);
please help me where i m wrong
|
|
|
|
|
Le@rner wrote: please help me where i m wrong
You've failed to say what is wrong.
Have you used the debugger to step through the code?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
And then what did GetLastError() return?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
GetLastError return "0x00000456 The media in the drive may have changed. "
|
|
|
|
|
Does this happen after the system comes out of Standby mode?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I am trying to create a statusBar in the dialog but it's returning false. not creating the status bar please tell me whats going wrong in this. Thanks for any help. I am creating the status bar in the OnInitDialog() function
[code]
CStatusBar m_wndStatusBar; // member variable in the dialog header.
BOOL CDlgsViewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return FALSE; // fail to create
}
m_wndStatusBar.SetPaneText(0,L"MainWindow Initialized");
}
[/code]
it's returning false. please help me.
|
|
|
|
|
|
You can create status bar by calling
m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,
CRect(0,0,0,0), this, 0);
You can have a look at Toolbar & StatusBar on Dialog[^]
|
|
|
|
|
thanks a lot it's working now.
|
|
|
|
|
I am disabling some menu items based on a condition but after some dialog launch in the application, these menu item appearance changes to those of enabled.
However, when I click them their appearance changes to that of a disabled button. I can also do this by simply switching focus or simply by minimize-restore of application.
Why does the menu item change appearance? How can I prevent that from happening?
|
|
|
|
|
Is this an MFC application? How are you disabling the menu items? From where, and how, are you launching the dialog box?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Yes this is a MFC application which works similar to the CProperty sheet wizard style but with CDialogs.
I am disabling the menu items in the frame class when the first dialog appears at start of the application but somewhere in between when other dialogs come up the appearance of the disabled menu items is changing from disabled to enabled.
|
|
|
|
|
To enable/disable menu items it is best practice to use the ON_UPDATE_COMMAND_UI message.
It also best practice to use a SDI (with a CFormView) application if menus are needed.
Watched code never compiles.
|
|
|
|
|
|
Hi,
It sounds to me as if your doing something that is screwing up the MFC command routing. However based on your brief description I have no ideas as to what it could be. Did you check to see if the menu items have a unique resource ID?
Best Wishes,
-David Delaune
|
|
|
|
|
|
|
Hi,
I see that you showed your EnableMenuItem() function on stackoverflow. If you would have gave us a better description and shown that function here on codeproject you would have recieved a much better response.
Best Wishes,
-David Delaune
|
|
|
|