|
Chandrasekharanp wrote: just wanted to know how do i display the directories of a system in a combo box.
Look up DlgDirListComboBox .
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
See CComboBox::Dir
- NS -
|
|
|
|
|
use the following code.Here m_letter is the member variable of combo box.
int k = 0;
DWORD MaxDriveSet, CurDriveSet;
DWORD drive, drivetype;
TCHAR szBuf[300];
HANDLE hDevice;
PSTORAGE_DEVICE_DESCRIPTOR pDevDesc;
for(k=0; k<26; k++)
szMoveDiskName[k] = '\0';
k = 1;
// Get available drives we can monitor
MaxDriveSet = CurDriveSet = 0;
MaxDriveSet = GetLogicalDrives();
CurDriveSet = MaxDriveSet;
for ( drive = 0; drive < 32; ++drive )
{
if ( MaxDriveSet & (1 << drive) )
{
DWORD temp = 1<<drive;
_stprintf(="" szdrvname,="" _t("%c:"),="" 'a'+drive="" );
="" m_letter.addstring(szdrvname);
="" switch="" (="" getdrivetype(="" szdrvname="" )=""
="" {
="" case="" 0:="" the="" drive="" type="" cannot="" be="" determined.
="" 1:="" root="" directory="" does="" not="" exist.
="" drivetype="DRVUNKNOWN;
" break;
="" drive_removable:="" can="" removed="" szmovediskname[k]="chFirstDriveFromMask(temp);
" szmovediskname[0]="k;
" k++;
="" drive_cdrom:="" is="" a="" cd-rom="" drive.
="" drive_fixed:="" disk="" sprintf(szbuf,="" "\\\\?\\%c:",="" 'a'+drive);
="" hdevice="CreateFile(szBuf," generic_read,
="" file_share_read="" |="" file_share_write,="" null,="" open_existing,="" null);
="" if="" (hdevice="" !="INVALID_HANDLE_VALUE)
" {
="" pdevdesc="(PSTORAGE_DEVICE_DESCRIPTOR)new" byte[sizeof(storage_device_descriptor)="" +="" 512="" -="" 1];
="" pdevdesc-="">Size = sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1;
if(GetDisksProperty(hDevice, pDevDesc))
{
if(pDevDesc->BusType == BusTypeUsb)
{
szMoveDiskName[k] = chFirstDriveFromMask(temp);
szMoveDiskName[0]=k;
k++;
}
}
delete pDevDesc;
CloseHandle(hDevice);
}
break;
case DRIVE_REMOTE:// The drive is a remote
drivetype = DRVREMOTE;
szMoveDiskName[k] = chFirstDriveFromMask(temp);
szMoveDiskName[0]=k;
k++;
break;
case DRIVE_RAMDISK:// The drive is a RAM disk.
drivetype = DRVRAM;
break;
}
}
}
|
|
|
|
|
Why this much since there is a simple solution available?
- NS -
|
|
|
|
|
i do understand that CComboBox::Dir works. but it working only for the current working directory.. i wnat to list out the total number of directories available on the system.
|
|
|
|
|
ya.For that only i have used the above code even though it is little bit lengthy.But it works perfectly.
|
|
|
|
|
But it is only for getting the drives, not directories. Am I right?
- NS -
|
|
|
|
|
ok.. will try that.. but u will have to tell me where to put that piece of code.
|
|
|
|
|
Chandrasekharanp wrote: but it working only for the current working directory..
That's wrong. Try this...
m_combo.Dir( DDL_EXCLUSIVE | DDL_DIRECTORY, "C:\\Windows\\*.*" );
Chandrasekharanp wrote: i wnat to list out the total number of directories available on the system.
For this case, AFAIK, you have to enumerate the directories. CFileFind class can help you.
- NS -
|
|
|
|
|
nothing is getting displayed in the combo box if i put the piece of code which u gave me.
|
|
|
|
|
That is awesome... that is a test code.
Anyway can you please show me the code segment? I need to know where and how you used it.
- NS -
|
|
|
|
|
it is working. but it is giving all the files and directories that is available in C. my requirment is not that. for example if there are 4 drives..ie(A,C,D,E). i need to print that A.C.D.E in the combo box. nothing else.
|
|
|
|
|
What I gave you is only an example. You can call it for any drive. Each call will add the list of directories to the existing list in the combo. If you need to get all the directories, as I said earlier, use CFileFind class recursively.
If you need only drives, specify the attribute as DDL_DIRECTORY.
- NS -
|
|
|
|
|
NS17 wrote: If you need only drives, specify the attribute as DDL_DIRECTORY.
Wrong. You should use DDL_DRIVES if what you want are drives.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: You should use DDL_DRIVES
Ooops... That's what I intended... Sorry for my careless typing (copy-pasting).
- NS -
|
|
|
|
|
Chandrasekharanp wrote: i need to print that A.C.D.E in the combo box.
These are drive designators, not directories (as your subject implies).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Send it a CB_DIR message. Use DDL_DIRECTORY | DDL_EXCLUSIVE for the WPARAM argument. If you are using MFC, the solution is even simpler.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
yes i am using MFC. how will i do it in MFC??
|
|
|
|
|
Did you overlook this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can we get the starting date from which history of IE is displayed in the history folder programatically.
|
|
|
|
|
FindFirstUrlCacheEntryEx/FindNextUrlCacheEntryEx specify URLHISTORY_CACHE_ENTRY, you'll have to check every entry and examine the times in the INTERNET_CACHE_ENTRY_INFO to find the earliest time.
|
|
|
|
|
Hi,
How to identify the already created application is SDI/MDI/Dialog based.
Thanks in advance
|
|
|
|
|
shir_k wrote: How to identify the already created application is SDI/MDI/Dialog based.
An option could be to check main window class using GetClassName.
AfxGetMainWnd()->GetClassName()...
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
Hi,
I've used the CTaskbarNotifier (found here) class in my project to show taskbar notifications. It works fine on Windows XP, but I've just seen that it's not so fine on Vista... The notifications have an ugly border.
You can see it on screenshots:
XP: http://alaf.sierp.net/xp.jpg
Vista: http://alaf.sierp.net/vista.jpg
Any idea how to get rid of that border?
Cheers,
Maciej
-- modified at 8:46 Monday 15th October, 2007
To be more specific:
The windows is created with the WS_POPUP style:
CreateEx(0,strWndClass,NULL,WS_POPUP,0,0,0,0,pWndParent->m_hWnd,NULL);
One thing comes to my mind, I don't have the Platform SDK for Vista, I am using the previous one, for Windows XP. Could the lack of Vista SDK be causing incorrect styling?
|
|
|
|
|
This is not really language specific but more of a source code parsing.
I have a large ASP source file that I like to split up, resulting in separate ASP files, each containing one function and the filename named after that function.
Does anyone know of a tool/script which does this?
PS: I am too lazy to learn Perl/AWK/Python to do this, hence why I believe someone has already written a tool/script to do this. Possibly in C++/etc.
|
|
|
|