|
Thanks kakan!
The code finally turned into
CString strDrive;
strDrive.Format("\\\\.\\%c:", 'C');
HANDLE hDrive = CreateFile(strDrive, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
DWORD dwRet;
BOOL bWritable = DeviceIoControl(hDrive, IOCTL_DISK_IS_WRITABLE, NULL, 0, NULL, 0,
&dwRet, NULL);
But the question is I have "C;D;E;F;G(CDROM)" drives, if I don't specify dwDesiredAccess as GENERIC_READ | GENERIC_WRITE, the returned hDrive for "C;D;E" is INVALID_HANDLE_VALUE, and all the accessable drives' hDrive(valid) is the same(0x000006f8). Is this normal?
|
|
|
|
|
and all the accessable drives' hDrive(valid) is the same(0x000006f8). Is this normal?
A handle's value is an opaque value to your program. It would only be ABNORMAL if you have OPENED more than a single drive simultaneously. If you are opening one drive at a time and then closing the handle, it would not be uncharacteristic for windows to recycle the handle value to you for each drive. If you opened two separate files or drives and got the same handle value back for both while they were BOTH opened, I would be concerned.
|
|
|
|
|
Hello LiYS.
Your second question is already answered, so I will try to answer yor first question.
To be honest, I'm not 100% sure, but my guess is that it isn't possible to open a CDROM-drive in GENEREIC_WRITE-mode.
In my own code, I first try to open the drive in GENERIC_READ | GENERIC_WRITE-mode. If it doesnt work, I try again, in GENERIC_READ-mode.
It seems to work at all times. But of course, if it's possible only to open the drive in GENERIC_READ-mode, then it's obviously read-only.
A comment: You should check your handle for INVALID_HANDLE_VALUE before calling DeviceIoControl.
kakan
|
|
|
|
|
Hi Kakan do you know how to make this code works under Win98?
|
|
|
|
|
Hi community,
how can i set a Textcolor in a CListCtrl for each Item?
In addiction from an Itemvalue i want to set a different Item's Textcolor!
Any Idea?
thanx
break;
|
|
|
|
|
Use NM_CUSTOMDRAW. Sample for this code will be like this
void MyDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = 0;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
crText = RGB(0,255,100);
crBkgnd = RGB(255,32,11);
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
}
}
|
|
|
|
|
Hi,
thanx, i it helps!
regards
break;
|
|
|
|
|
every wav file have it's own format described by the WAVEFORMATEX struct,I want to get a copy of a wav file with changing it's WAVEFORMATEX .So what can I do?
|
|
|
|
|
Pass the data through the audio compression manager to change its format for you.
|
|
|
|
|
I'm using a class derived from CHtmlView as listview in an internal Folder
Browser of my application.
Exist a facility to hide the left blue task pane (if user have activate this
feature in Folder Options)?
Another fine feature will be, to set the "list" as active default view in my
application (may be the user has set "icon" as default). Any idea?
Thx for help
|
|
|
|
|
What is density sampling?
How can it be used in image resizing?
Pls help
|
|
|
|
|
Write a program in c language to print prime number using recursion
rajesh
|
|
|
|
|
//it will print the no which r prime no and greater than 9
void divisiblity(int divident,int divisor);
main()
{
const int divisor=9;//keep it const
int divident=10;
while(1)
{
divisibility(divident,divisor);
divident++;
}
}
void divisibility(int divident,int divisor)
{
if(divisor==1)
{
printf("the no is a prime no\t%d",divident)
return ;
}
int remainder=divident%divisor;
if(remainder==0)
return;
divisibility(divident,divisor-1);
return;
}
hope this may help u
-- modified at 6:43 Wednesday 26th October, 2005
|
|
|
|
|
you suck !!
do your homework by yourself.
assignments are made to make you progress ; asking someone to do it for you will never deserves you.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Rajesh_K_Sharma wrote: Write a program in c language to print prime number using recursion
Anything else ?
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
a beer please... that's very URGENT !!!!!!!
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
BEER are not allowed in public places ;P
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: BEER are not allowed in public places
even non alcoholized ones ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: even non alcoholized ones ?
Yeap
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
[under_the_table] [/under_the_table]. C'mon toxxct, finish it fast before somebody sees u, particularly Mr.ALok
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
|
|
|
|
|
VivekuniQ wrote: particularly Mr.ALok
Cut the mr. from Alok....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
rajesh
I have modified the program .Check it
-- modified at 6:49 Wednesday 26th October, 2005
|
|
|
|
|
whats the best way to read ini files and store the input configuration for a program in a class that will be used throughout the program. I want to have a STL map for each section, and read the name/value pairs in each section into the map. Is this a good way to keep the configuration? What are the other general approaches people follow in keeping the config in memory?
What is the way to enumerate the name/value pairs in a given section?
Does each call to GetPrivateProfile* parse the INI file again? Is this why they take the INI file name as a parameter?
thanks!
|
|
|
|
|
Lambu Jindu wrote: whats the best way to read ini files and store the input configuration for a program in a class that will be used throughout the program. I want to have a STL map for each section, and read the name/value pairs in each section into the map. Is this a good way to keep the configuration? What are the other general approaches people follow in keeping the config in memory?
Yeah thats the good way! till you ini file info doesn't change between execution of program!
Lambu Jindu wrote: Does each call to GetPrivateProfile* parse the INI file again? Is this why they take the INI file name as a paramet
Yeap, you are thinking in right way! it reparse the ini file every time it call it!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Lambu Jindu wrote: whats the best way to read ini files...
With GetPrivateProfileString() and GetPrivateProfileInt() .
Lambu Jindu wrote: Is this a good way to keep the configuration?
How often do you need the values? Do you want the values to be able to be changed while your program is running, or must your program be restarted?
Lambu Jindu wrote: What is the way to enumerate the name/value pairs in a given section?
Using GetPrivateProfileSection() .
Lambu Jindu wrote: Does each call to GetPrivateProfile* parse the INI file again? Is this why they take the INI file name as a parameter?
Yes.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|