|
In additional FindFirstFile()/FindNextFile() use of SHFileOperation or DeleteFile
|
|
|
|
|
In code how can we distinguish a removable drive whether it is a CD/DVD or an USB removable drive (pen drive, flash memory reader/writer)? I used the SDK function GetLogicalDrive() to collect the drive letter and DeviceIoControl() to check if the drive is removable but I don't know how to tell if the drive is a CD/DVD drive or a pen drive asumming that I have both unformatted CD in the CD drive and pen drive in the USB port.
My objective is to format the pen drive from code. At the moment, I rely on the user to select the correct drive. But if he choose the CD drive by mistake, an attemp to format the CD for FAT system would crash the program or put the format call into a loop forever (I spawn to call format.com to format the drive).
Any help would be greatly appreciated. Thanks in advance
|
|
|
|
|
Try GetDriveType to see if that helps make a distinction.
The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
Return Values
The return value specifies the type of drive. It can be one of the following values.
Value Meaning
DRIVE_UNKNOWN The drive type cannot be determined.
DRIVE_NO_ROOT_DIR The root path is invalid, for example, no volume is mounted at the path.
DRIVE_REMOVABLE The drive is a type that has removable media, for example, a floppy drive or removable hard disk.
DRIVE_FIXED The drive is a type that cannot be removed, for example, a fixed hard drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.
Maybe you get different value for CD-ROM and the Pen Drive ?
|
|
|
|
|
Thanks Blake. My problem is on the labtop, the CD drive is removable and GetDriveType() would return all removable drive "DRIVE_REMOVABLE"
|
|
|
|
|
If you have code that goes into an infinite loop or crashes, you need to first fix that code!
Have you looked at the SHFormatDrive(...) function? You can use it to format a drive (after you have determined that you should be formatting it).
You did not mention if you were getting user permission or not, so I would think this is a bad idea. You would have to put some extra code in there to make sure you are not formatting a volume that is in use, and that you really have the one you want. What if the user had multiple storage devices plugged in at once? Which one would you be formatting...?
This sounds like a very dangerous thing to do without first having the user confirm the format action. You could find yourself dealing with a lawsuit over lost data.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks James. I thought the infinite loop was because the spawn to format.com never return when a removable CD drive was selected. I can prevent this by checking the media type before formatting. That's what prompted this question.
Yes, SHFormatDrive would do the same job.
I do prompt warning to the user before format the media. Your suggestion to check for user permission is a good idea as the extra precaution. I didn't think about it. Thanks
|
|
|
|
|
Please anyone can send a sample application using CAsyncSocket for communicating two clients which are in different ports. Thanks.
Regards,
Vijaya
|
|
|
|
|
wrote: Please anyone can send a sample application using CAsyncSocket for communicating two clients which are in different ports. Thanks.
This[^] will make a good read.
|
|
|
|
|
Hi you back to the codeproject
|
|
|
|
|
WhiteSky wrote: Hi you back to the codeproject
Yes. I was always here. Didn't find the time to post replies or queries.
|
|
|
|
|
Nibu babu thomas wrote: I was always here
Welcome;)
|
|
|
|
|
|
Hi !!!
In my application,I have created one dialog box which showing preview of the symbol.Now i want to insert this symbol in my Application( Autocad).How can i insert this??
Ie if I will click OK button from Dialog box then symbol (preview)should be insert in the Autocad.??
Thanking you
Shah
|
|
|
|
|
AutoCad[^]? Your application?
Shah Satish wrote: How can i insert this?
Really hard to tell.
I assume that the preview is not the actual object that is to be inserted, but rather a small bitmap or similar just to show the user how it looks.
You have to describe the "symbol". What is it? An OLE object, picture or what?
You have to describe the target as well.
What kind of application is it? What does it mean to "insert" a "symbol"?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Symol is from my file..Like C:\\Symbol\\Exchangers\\Exchanger_1_i.dwg
(here Exchanger_1_i.dwg is the symbol and its Autocad drawing)
This is the preview of the dialog box.
|
|
|
|
|
Ok... This is how I understood you so far:
It is the actual commercial CAD application AutoCad and the "symbol" you want to insert is an AutoCad drawing.
So the question is really about "how do I insert an AutoCad symbol in an AutoCad drawing"?
Man, you really picked the wrong forum for this question... Try AutoCad support.
Actually I don't think this is the case, but if I only read the things you're writing, that would be the only conclusion.
The questions in my previous post was meant to narrow the problem down and trying to understand what you're trying to do and how you're trying to do it. At least try to answer those questions if you still want some help.
Perhaps I cannot help you, I don't know that yet since you haven't described your problem in an understandable way, but there might be someone else that can. They would ask you similar questions however.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Yeh..You got my question correctly..
See my code..
BOOL CDwgPvDLG::OnInitDialog()
{
CDialog::OnInitDialog();
m_mytext.AddString(_T("Exchanger-Double end"));
m_mytext.AddString(_T("Exchanger-Single end"));
m_mytext.AddString(_T("Exchanger-Double end kettle"));
m_mytext.AddString(_T("Exchanger-Single end kettle"));
m_mytext.AddString(_T("Exchanger-Super"));
m_mytext.AddString(_T("Exchanger-Process Flow"));
if (str == _T("")) {
m_mytext.SetCurSel(0);
mydwg = _T("C:\\Symbol\\Exchangers\\Exchanger_1_i.dwg");
}
else{
m_mytext.SelectString(-1,str);
}
this->Invalidate(FALSE);
return TRUE;
}
void CDwgPvDLG::OnPaint()
{
CDwgPreview ::ShowInDialog (mydwg,this,IDC_PVTYP);
CPaintDC dc(this);
}
void CDwgPvDLG::OnselectionchangeList()
{
int nEntry = m_mytext.GetCurSel();
const IndexEntry *pEntry = m_pPermutedIndex->GetIndexTableEntry(nEntry);
this->Invalidate(FALSE);
}
void CDwgPvDLG ::OnOK()
{
CDialog::OnOK();
m_mytext.GetText(m_mytext.GetCurSel(),str);
}
Shah
|
|
|
|
|
In your code, you can probably call your class roughly like this:
CDwgPvDLG m_DwgPv;
if( IDOK == m_DwgPv.DoModal()) {
CString DWGItem = m_DwgPv.str;
//do whatever you want with the string the user did select in the dialog
}
Hope this helps?
Feel free to ask more.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Thanks for reply..But this is code for Calling dialog box..I have alreday call dialog box through command..only step is how to insert file ( for exmple this is my string n now i want to insert ..("C:\\Symbol\\Exchangers\\Exchanger_1_i.dwg")
every thing should be in On ok().. like..
void CDwgPvDLG ::OnOK()
{
CDialog::OnOK();
m_mytext.GetText(m_mytext.GetCurSel(),str);
ads_point point;
acedGetPoint(NULL,(_T("\nPick position : ")),point);
}
|
|
|
|
|
Shah Satish wrote: every thing should be in On ok().. like..
That is bad style. Have the Dialog do one thing (i.e. get a selection from the user) and do the work from where the dialg had been called.
Possibly by opening other dialogs to get the user to answer more specific questions.
Or are you doing a dialog-based application and this is your main dialog?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Yeh..This is MFC dialog based application and this is only one and main dialog box..
Your method is also good but main thing is How to insert ??
|
|
|
|
|
Shah Satish wrote: Your method is also good but main thing is How to insert ??
I have not the faintest idea of how to handle a dwg-file.
You would need to know the format, read it, parse it, build an internal representation of it and draw that.
Sorry, but I don't think I can help you with that specific problem.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I am trying to use a well-documented method to subclass across processes in windows (See the following
http://www.codeproject.com/dll/subhook.asp[^]
Specifically, I'm trying to subclass the taskbar so I can grab WM_PAINT messages and control how my app's taskbar button is drawn. Actually, this is cross-platform development, and in modern window systems the windows taskbar is a ToolbarWindow32 in Win98 its a SysTabControl32.
But anyway, the method to subclass is to do a SetWindowsHookEx to the thread of the desktop control using a dll hook procedure (to get into its process address space) and then immediately subclass the control windproc and unhook.
What I encounter is the following:
I can callSetWindowsHookEx for a specific thread, and windows returns OK, but when I try to send a message to the control (in this case SysTabControl32) my hook proc doesn't pick up the message. (I'm using a WH_WNDPROC hook).
Or, I can call SetWindowsHookEx and specify 0 for the thread (thus making it system-wide) and then my hookproc picks up the init msg, but when I try to subclass, SetWindowLong(...GWL_WNDPROC...) returns 0, so the system-wide hook isn't getting me into the desktop control address space.
In any case, the thread-specific hook SHOULD work, and according to windows, the hook is created, but it never picks up my init msg.
Incidentally, this problem I'm encountering is currently under Win98 (don't ask why). But the specific method of subclassing I'm using is supposed to be the most reliable, and valid across all versions of Windows, past and present.
There's some crucial detail I'm forgetting that would enable me to subclass the windows taskbar. Does anybody know what it is?
|
|
|
|
|
K this is really frusterating. All i need to do is place the exact string representation of an int into the edit control. But the problem is that int is not only thing i need to print to the edit control. So what i need help on is how do get the index of a target line from the edit control, and how do i place a char or int in the target line? I read the win32 api at microsofts website, but did not find what i was looking for. Please please help!
|
|
|
|
|
Can you post some example of what exactly do you want to achieve.
Alternatively, you can store the data from the edit control into a char* and then make changes to the string. Later when you are done with this you can update the edit control to show the new string. I hope that I understood you.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|