|
Hello all,
i am using ReadFile function to Read a Sector from different type of storage devices like Pen Drive, Hard Disk, Memory Card iPod.
with all devices excluding iPod it is working fine means it return 1.
when i am trying to Read iPod it fails means it return 0;
i am using apples 120 GB iPOD, and when i try to get error Code by using
DWORD dw = GetLastError();
it is 87
/////used by window9x
long drive_num;
int sector, disk_read;
int drive_no;
char drv,szflp_drv[20];
strcpy(szflp_drv , "\\\\.\\a:");
char phydisk[20];
strcpy(phydisk,p);// p is a string like "\\\\.\\PhysicalDrive0",+"Drive No"
//Ex. if Drive No.3 then "\\\\.\\PhysicalDrive3",
drv = p[17];
/////used by windowsnt
HANDLE hCD;
DWORD dwNotUsed;
drive_no = atoi(&drv);
///////////////////////////////////
//////Check which os is installed
hCD = CreateFile (phydisk, GENERIC_READ ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
if (hCD != INVALID_HANDLE_VALUE)
{
DWORD dwSize = total_sector * 512;
__int64 y=512*start_sector;
__int64 ss= myFileSeek(hCD,y,FILE_BEGIN);
int aa;
aa = ReadFile (hCD, buffer, dwSize, &dwNotUsed, NULL);
DWORD dw = GetLastError();
}
|
|
|
|
|
Shiv Murti Pal wrote: DWORD dw = GetLastError();
it is 87
First clue:
87 = ERROR_INVALID_PARAMETER
|
|
|
|
|
where is error plese suggest me
|
|
|
|
|
It means that one of the parameters (probably for ReadFile) is invalid. Use the debugger and check the values.
|
|
|
|
|
Before executing the value of ReadFile Parameters are
int aa;
aa = ReadFile (hCD, buffer, dwSize, &dwNotUsed, NULL);
hCD = 0x00000798
buffer = 0x0012f1bc
dwSize = 512
dwNotUsed = 3435973836
NULL
After executing the value of ReadFile Parameters are
dwNotUsed = 0
All other are Same
Note:- in case of all other devices where the ReadFile return success (1)
dwNotUsed = 512
Now Sir suggest me what i should do
|
|
|
|
|
Have you seen the Return Value section of MSDN?
If the function succeeds, the return value is nonzero.
If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
If the return value is nonzero and the number of bytes read is 0 (zero),
the file pointer is beyond the current end of the file at the time of
the read operation. However, if the file is opened with FILE_FLAG_OVERLAPPED
and lpOverlapped is not NULL, the return value is 0 (zero) and GetLastError
returns ERROR_HANDLE_EOF when the file pointer goes beyond the current end
of file.
What is the value of aa when the function returns? Try calling GetLastError() to get more information.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
the value of aa is 0 i have already explained
|
|
|
|
|
hello sir/Madam (Michael Schubert)
Sir please guide me sir, i think u ware only one step away from solution, in your last responce please help sir
|
|
|
|
|
Hi,
How to generate Keyboard events.
I want to generate Alt+Tab Event in middle of my application.
How to generate Alt+Tab event in a dialog based application.
Thanks in advance.
With best wishes.
|
|
|
|
|
Just call SendMessage to the intended window, giving the arguments the value you want to expect from that event.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
SendInput[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
You can use either SendMessage() or PostMessage() depending on you requirement.
There are a few subtle differences in the ways you can send messages in Windows, but the basic difference between PostMessage and SendMessage is that SendMessage sends a message to another window immediately by calling that window's procedure and waiting for it to return, whereas PostMessage queues the message in an MSG structure and returns immediately"without waiting. MSG is short for message, not monosodium glutamate.
With SendMessage, the receiving app processes the message immediately, rather than at some later time, by fetching it from its queue. For example, suppose you write:
pWnd->SendMessage(WM_KEYDOWN);
pWnd->PostMessage(WM_KEYDOWN);
There are different indicators for which key was pressed .Kindly, go through that list and do the apporopiate
Kushagra
I hate coding but I love to develop
|
|
|
|
|
Thank you.
Using keybd_event how to generate Alt+Tab.
I tried both of the below options but failed.
1 ------------
keybd_event( VK_MENU ,0x45,KEYEVENTF_EXTENDEDKEY | 0, 0 );
keybd_event( VK_TAB ,0x45,KEYEVENTF_EXTENDEDKEY | 0, 0 );
keybd_event( VK_TAB ,0x45,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
keybd_event( VK_MENU ,0x45,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
2 ------------
keybd_event( VK_MENU | VK_TAB ,0x45,KEYEVENTF_EXTENDEDKEY | 0, 0 );
keybd_event( VK_MENU | VK_TAB ,0x45,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
Please let me know how to use for Alt+Tab combination to change the window.
|
|
|
|
|
There is small mistake in the code
hardware scan code is wrong it should be for alt 0X12 and for tab 0X09
i put delay just to see the output.
keybd_event( VK_MENU ,0x12,KEYEVENTF_EXTENDEDKEY | 0, 0 );
Sleep(1);
keybd_event( VK_TAB ,0x09,KEYEVENTF_EXTENDEDKEY | 0, 0 );
Sleep(1000);
keybd_event( VK_TAB ,0x12,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
keybd_event( VK_MENU ,0x09,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
|
|
|
|
|
Hi,
I am working on a TCP server application.
Can I get the computer name of a connected client using its IP?
I am using getnameinfo(), but its giving only the IP.
I want to get the computer name as I already having the client IP.
Please help me.
Regards,
Sunil Kumar
|
|
|
|
|
getnameinfo[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The getnameinfo API ask the DNS for the IP to Name resolution.
In general, getting a name from an IP requires a reverse DNS lookup to be configured in the DNS.
That's not granted to happen for clients and dynamic addresses across the Internet.
It works properly only if you are in coherently administrated network.
Otherwise it is mostly impossible.
Have a talk with your network administrator on how DNS works in your company.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I want to handle WM_KEYDOWN and WM_CHAR messages in Combo Box.I subclassed the combo box's control and added those messages.But its not working. How can i handle this messages.
|
|
|
|
|
Is it an editable combo box? If so, you probably should subclass the edit field instead of the combo itself. Also you could try overwriting PreTranslateMessage for the combo, maybe those messages cross it before trabslation, am not sure.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Dear All,
I have resource sharing issue in my MFC programming. Below, I will describe the scenario.
I am using VC++ 6.o version
I have a dialog(modeless) based application.
Main dialog box has a Button( say "Button1" ) with OnButton1(), that will call member function DisplayChildDialog()
I have a worker thread also, that will call DisplayChildDialog() using PostMessage() of main dialog.
DisplayChildDialog() will dispaly a child dialog(modal). Child dialog's object is created locally in DisplayChildDialog().
So DisplayChildDialog() will always called from the GUI thread.
Scenario:
When I clicks on "Button1", OnButton1() will call a member function DisplayChildDialog() and a child dialog(modal) will appear.
This time worker thread will also call DisplayChildDialog() using PostMessage() of Main dialog.
When I click on "Button1" DisplayChildDialog() will also call from worker thread using PostMessage(). of the main dialog. So two dialogs will appear simultaniously.
To avoid this situation I made the second caller of DisplayDialog() to enter in a MessageLoop, and will check a flag that will infrom whether the first caller has left the DisplayChildDialog() or not.
I wrote the message loop in DisplayDialog() like this.
DisplayDialog()
{
if( CChildDlg::m_bDisply == true )
{
while( GetMessage( &stMsg, 0, 0, 0 ))
{
TranslateMessage( &stMsg );
DispatchMessage( &stMsg );
if( false == CChildDialog::m_bDisply )
{
OutputDebugString( _T( "### Message loop false************************" ));
return;
}
}
}
CChildDlg::m_bDisply = true;
CChildDlg objChild;
objChild.DoModal();
CChildDlg::m_bDisply = false;
}
But this will work 5 or 6 times correctly. But after that, when I clicks on "Button1", the first caller of DisplayDialog() will terminate before showing the dialog box it will just make CChildDlg::m_bDisply = true. So the second caller will enter in Message loop and never exit.
I tried this too instead of above given message loop:
while( CChildDlg::m_bDisply && WaitMessage())
{
AfxGetApp()->PumpMessage();
}
But both given same result..
Please help me.
|
|
|
|
|
How can it terminate without showing the dialog and leave your flag set to true?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi All,
I need to make "make File" while building my code in VS 2005. please guide me
Thanks
Bankey
|
|
|
|
|
what makefile u r talking about.will u explain in detail?PLease.
|
|
|
|
|
actually i need to build VC++ Project from command prompt...so i think that, we can do it by using "MakeFile".
|
|
|
|
|