|
Hi Guys,
This question I asked earlier, but I could nt continue,
I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )?
Please do reply guys.
Thanks in Advance
Velayudhan
|
|
|
|
|
velayudhan_raj wrote: This question I asked earlier, but I could nt continue,
I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )?
Please do reply guys.
GetLogicalDriveStrings();
|
|
|
|
|
It is not completely successful.
It is just returning a single drive's name
Actually I want all the name's of all drives in my system.
Thanks in Advance
Velayudhan
|
|
|
|
|
velayudhan_raj wrote: It is not completely successful.
It is just returning a single drive's name
Actually I want all the name's of all drives in my system.
You should first read the documentation carefully
Quote from MSDN...
lpBuffer
[out] Pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, that end with a second null character. The following example shows the buffer contents with <null> representing the terminating null character.
c:\<null>d:\<null><null>
End quote...
I guess you are trying to assign to a string which terminates where it finds a null character, hence you are not able to get the whole drives.
|
|
|
|
|
Dear Velayudhan,
I am Listing in LisBox, u can display it in any control.
Here is the Code.....
unsigned long driveList = GetLogicalDrives();
char drivePathName[] = " :\\";
CString drive;
for(int i = 1;i<26; i++) //u can give no of drives in your system
{
if(0x01 & (driveList >> i))
{
drivePathName[0] = 'A' + i;
drive.Format("%c",drivePathName[0]);
m_List.AddString(drive);
}
}
With Best Regards
Vidya
S/W Developer,
AnnetSite,Mumbai
|
|
|
|
|
How to use this function
<br />
char *m_Name=new char[256];<br />
DWORD Lenght=255;<br />
GetLogicalDriveStrings(Lenght,m_Name);<br />
...<br />
...<br />
-- modified at 10:25 Wednesday 6th September, 2006
|
|
|
|
|
WhiteSky wrote: How to use this file
What file?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
function
|
|
|
|
|
Fair enough. But the OP already knew how to use the function. He was troubling parsing the resulting buffer.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Each drive letter is separated by a nul character. Try:
char szDrives[105] = {0};
GetLogicalDriveStrings(sizeof(szDrives), szDrives);
char *pToken = szDrives;
while (*pToken != '\0')
{
cout << pToken << endl;
pToken += 4;
}
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Is There any short way to remove some lines from a file say there is a file called
Hello.dat contains 5000 lines
1) In that i just want read first 200 lines
2) Preform some operation
3)remove them i.e. 200 lines if the operation is proper //This is the problem
Some efficient was i.e. without creating another file i.e. new file
Payal
|
|
|
|
|
payal335 wrote: Some efficient was i.e. without creating another file i.e. new file
you have too make a new file for this.. there is no other option!
"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
Support CRY- Child Relief and You
|
|
|
|
|
payal335 wrote: Is There any short way to remove some lines from a file say there is a file called
Hello.dat contains 5000 lines
1) In that i just want read first 200 lines
2) Preform some operation
3)remove them i.e. 200 lines if the operation is proper //This is the problem
CFile::SetLength is one option, but you will have to do some additional work like counting the number of lines ( in your case 200 ).
|
|
|
|
|
Unfortunately, it seems the Operating System does not allow shortening of a file by removing data at the beginning. It only allows truncation of the tail. Therefore I think it is not possible to solve your problem without read and write operations (on the same or two files).
But I would consider the following approach. The first value of your file should be reserved: it will contain the position of the first line that should be read. After you read your 200 lines, simply rewrite the first value. These lines are still in the file, but are ignored on next operations.
So you have to deal with GetPosition and Seek members of CFile .
Instead of storing the position in the same file, you can store it in a separate file or in memory.
This way the file will grow when you append new lines, therefore you should really remove unneeded head lines periodically.
I hope this helps.
|
|
|
|
|
Thank you all for putting u r valuable time
payal
|
|
|
|
|
Hi,
I have data as log file, then i want to display that data in tabler format. so how can i do in my vc++ application.
Also I want to use bar chart and it should be support event. so what kind of chart control can I use.
please reply me if anybody know.
partha.s@papyrus.ne.jp
bye
parthasarathy
|
|
|
|
|
victorsarathy wrote: so what kind of chart control can I use.
please reply me if anybody know.
try google[^]
"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
Support CRY- Child Relief and You
|
|
|
|
|
Hi All,
I am unable to work out the reason for the extra consumption of memory in the following code. This is just some code I was experimenting with. I am using the winldap libraries.
void TestInitialisation()
{
//LDAP* ldap = ldap_open(NULL, NULL);
LDAP* ldap = ldap_init(NULL, NULL);
if(ldap)
{
//ldap_set_option(ldap, LDAP_OPT_ROOTDSE_CACHE, LDAP_OPT_OFF);
//ldap_set_option(ldap, LDAP_OPT_CACHE_ENABLE, LDAP_OPT_OFF);
ldap_unbind(ldap);
}
else
assert(false);
}
The lines that I have commented are the options that I have tried, but they dont seem to make any difference. I also noticed that consequitive calls to TestInitialisation() will result in a leak too, but the number of calls to get a leak happening is not consistent. I found it useful to write up a small dialog application with a button press event that called TestInitialisation().
I would appreciate any ideas and help on this.
Thanks,
|
|
|
|
|
Is this code in a loop? if so did you remember to call ldap_unbind() . Each time you call ldap_open() you are creating a new handle, so unless you close it you will have a handle leak. You could also try adding static to the ldap_open() line, which would cause it to only be called on the first loop.
|
|
|
|
|
Hi all:
I'd like to avoid the reboot while installing the MSI package, I have some clues but they are not worked as expected.
MsiInstallProduct(szPath, _T("REBOOT=ReallySuppress"))
After executing the above line the system rebooted without any warning. How can I really suppress the reboot?
|
|
|
|
|
Problem solved
you have to add the "ACTION" property too
So, final statement will be
MsiInstallProduct(szPath, _T("ACTION=ADMIN REBOOT=ReallySuppress"))
|
|
|
|
|
When i run m program i got this erroe how to solve this
C:\myproject\wartz_new\wartz_newDlg.cpp(194) : error C2039: 'GetLineCount' : is not a member of 'CString'
This is the sample code
<br />
m_MainEdit=m_MainEdit+"<Session ID :>" + sessionid +"\n";<br />
UpdateData(FALSE);<br />
iLineCount=m_MainEdit.GetLineCount();<br />
m_EditCtrl.LineScroll(iLineCount);<br />
|
|
|
|
|
I don't know what you are trying to do but a CString object is 'just' a string. So, there is no information about line count.
|
|
|
|
|
yes because CEdit::GetLineCount
|
|
|
|
|
and i guess you need to CString::GetLength
iLineCount=m_MainEdit.GetLineCount();
iLineCount=m_MainEdit.GetLength();
|
|
|
|