|
If you don't want to write any program for the same , try following.
If you are talking about C or D drive, go to root of the drive & fire following command.
"dir /S /ON /AD /B > AllFolder.txt"
All the folder will be listed in AllFolder.txt
|
|
|
|
|
Yes, i wanna write a program in MFC to list all the Folder that Shared fully in Hard Drive (C:; D . But I don't know how to approach, Could you help me any more??
thanks
|
|
|
|
|
Hi
If I'm not wrong, an element in STL map is a pair of <key, data>. Given a map of a number of elements, how can I use STL algorithms like for_each(), accumulate(), etc on just the data, ignoring the keys?
Thanks!
|
|
|
|
|
The parameter of the for_each predicate is the result of dereferencing an iterator, which in the case of a map is a map<key,value>::value_type , or pair<const key,value> . So the predicate can look at the second member of the pair :
#include <map>
#include <algorithm>
typedef map<char,int> mymap;
struct TotalIt
{
void operator()( mymap::value_type elt )
{
m_total += elt.second;
}
int m_total;
TotalIt() : m_total(0) { }
};
int main()
{
mymap M;
M['a'] = 1;
M['b'] = 2;
M['c'] = 3;
M['d'] = 4;
M['e'] = 5;
for_each ( M.begin(), M.end(), TotalIt() );
}
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
If my rhyme was a drug, I'd sell it by the gram.
|
|
|
|
|
How about this?
#include <iostream>
#include <map>
#include <iterator>
#include <numeric>
template <typename I> class Pair2ndIterator : public I
{
public :
Pair2ndIterator ( I i ) : I ( i )
{
}
typename I::value_type::second_type& operator* ()
{
return (I::operator*()).second ;
}
} ;
template <typename I> Pair2ndIterator<I> MakePair2ndIterator ( I it )
{
return Pair2ndIterator<I> ( it ) ;
}
int main()
{
std::map<char, int> mymap ;
mymap.insert ( std::make_pair ( 'a', 10 )) ;
mymap.insert ( std::make_pair ( 'b', 11 )) ;
mymap.insert ( std::make_pair ( 'c', 12 )) ;
mymap.insert ( std::make_pair ( 'd', 13 )) ;
mymap.insert ( std::make_pair ( 'e', 14 )) ;
std::cout << "Accumulate ( mymap ) = " <<
std::accumulate ( MakePair2ndIterator ( mymap.begin ()),
MakePair2ndIterator ( mymap.end ()), 0 ) ;
return 0;
}
Paul
|
|
|
|
|
How can I append data to an existing file without overwriting the contents? I thought I could position the pointer at the end using SeekToEnd() and then write to it but it doesn't work that way. Thanks!
|
|
|
|
|
Position the file pointer at the end of the file before writing to it:
SetFilePointer ( hFile, 0, NULL, FILE_END );
[edit]Corrected order of the parameters[/edit]
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Fascinating - in some of my code, I used:
SetFilePointer( hFile,
0,
NULL,
FILE_END);
i.e. I have FILE_END and 0 reversed - this also works fine.
I wonder how often you can swap parameters in an API call!
|
|
|
|
|
|
This means I'd have to open the file using CreateFile(). I'm using CFile::Open() to open the file so is there a way to do it this way? I need to create a report that needs to follow a specific format and I'm writing to the file as I go through each set of data. Does CFile not have a function that takes you to the end of the file in order to append the data or some kind of access rights that allow appending?
|
|
|
|
|
I'm tring to find a way to lookup a particular path in the DFS tree to find where the actual resource from what points to it.
I can't seem to find any API calls or objects which deal with this. The simple way is to pipe 'dfscmd.exe /view \\server\dfsshare /batch | grep path_feaure | awk '{print $4}'' and parse that output but it is ugly and I have to install dfscmd, grep and awk on each machine that needs this code.
Does anyone know where I can find some way to do lookups in a DFS tree programatically?
I know i can use NetShareGetInfo to find out if a path is a DFS root but that's as close as I've come (with a hour of google and msdn searches).
Any points in a relevant direction would be extremely helpful.
|
|
|
|
|
Sorry this post is from me and by DFS tree I mean (D)istributed (F)ile (S)ystem [not Depth First Search].
I forgot to login before I posted the message.
My apologies.
Sean
|
|
|
|
|
The article here is really great:
http://www.codeproject.com/listctrl/listeditor.asp
When I run the project and click on an edit box, the box
with focus looks like:
_ _
|________________|
The top part of the box is open and it looks funny. Any
chance any came across this and knows how to make it look
like a full box? Please, any response any one can give
me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
How about posting the question at the messageboard underneath the article you mentioned? At least, it has more relevancies.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I'm working on a frontend to an old dos program, and am at the point where i need to interact with the backend.
I was planning on using the System() call, but was wondering if there's a better way to interface with other programs. For instance, i'd like to know if the backend dos program is still running, or if the program has crashed.
Does VC++ provide a method to do this?
Thanks,
Mike
"I bet Einstein turned himself all sorts of colors before he invented the light bulb." -- Homer J.
|
|
|
|
|
Here is an example nicked from MSDN:
#include <windows.h>
#include <stdio.h>
#define MAXNAMELEN 255
#define CMDLINE "/c dir"
#define IMAGENAME "\\nt\\bin\\cmd.exe"
#define WINTITLE "CreateProcess DEMO"
main(){
BOOL fSuccess,fExit;
DWORD dwExitCode,dw;
STARTUPINFO SI;
PROCESS_INFORMATION pi;
HANDLE hProcess,hThread;
SI.cb =sizeof(STARTUPINFO); SI.lpReserved = NULL;SI.lpDesktop=NULL;
SI.lpTitle="CreateProcess DEMO";SI.cbReserved2=0;SI.lpReserved2=NULL;
fSuccess = CreateProcess((LPTSTR)IMAGENAME, (LPTSTR)CMDLINE,
(LPSECURITY_ATTRIBUTES)NULL,
(LPSECURITY_ATTRIBUTES)NULL,
(BOOL)TRUE,(DWORD)0,NULL,NULL,
(LPSTARTUPINFO)&SI,(LPPROCESS_INFORMATION)&pi);
if (fSuccess) {
hProcess = pi.hProcess; hThread = pi.hThread;
printf("Process Id = %d\nThread Id = %d\n",pi.dwProcessId,pi.dwThreadId);
dw = WaitForSingleObject(hProcess, INFINITE) ;
if (dw != 0xFFFFFFFF) {
fExit = GetExitCodeProcess(hProcess, &dwExitCode) ;
}
CloseHandle(hThread) ; CloseHandle(hProcess) ;
printf("COMPLETED!\n");
}
else printf("Failed to CreateProcess\n");
}
The same method can be used in a GUI-app as well.
|
|
|
|
|
perfect. thanks a million.
Mike
"I bet Einstein turned himself all sorts of colors before he invented the light bulb." -- Homer J.
|
|
|
|
|
Hey, I'm having a problem figuring out how to interpret strings as packed binary data in C++ like you can in Python (see http://www.python.org/doc/current/lib/module-struct.html)
I'm not sure how to go about this, but I need to get the file size and checksum from a file to be able to read separate files from a file package (I'm designing an extractor for it).
This is how you do it in python:
(size,chksum) = unpack(">ii", size_chksum)
size_chksum is 8 bits, the first 4 being the size, and the second 4 being the checksum, it splits it into the variables size and chksum.
This is what one person told me to do in C++, where size is the 4 bits (checksum not used here):
size_int = size[3] << 8 | size[2] << 16 | size[1] << 24 | size[0];
Anyone got an idea???
-NizZy
|
|
|
|
|
LOL
I meant bytes, not bits!
hehe
|
|
|
|
|
Hello All, I'm writing client/server programs using named pipe.
In the server program,
when the user click on a button, it create a thread. Inside a thread function, CreatePipe is called first then listen to client.
Here the code how server program creates the pipe and the thread function
<br />
UINT theThreadFunction(LPVOID lParam)<br />
{<br />
ServerApp *s = (ServerApp*)lParam;<br />
s->CreatePipe();<br />
while(!stop)<br />
{<br />
s->CommunicateWithClient();<br />
}<br />
}<br />
<br />
void ServerApp::CreatePipe()<br />
{<br />
CString temp = "\\\\.\\pipe\\Server"; <br />
LPCTSTR lpszPipename = (const char*) temp;<br />
<br />
hPipe = CreateNamedPipe( <br />
lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
NMPWAIT_USE_DEFAULT_WAIT,
NULL);
if (hPipe == INVALID_HANDLE_VALUE) <br />
{<br />
MessageBox("CreatePipe failed"); <br />
enableDlgItems = true; <br />
return ;<br />
} <br />
}<br />
<br />
void ServerApp::CommunicateWithClient()<br />
{<br />
...<br />
bool fConnected = ConnectNamedPipe(hPipe, NULL);
...<br />
}<br />
The client application get executed before the Server Application gets executed.
The client used the following code.
<br />
bool ClientApp::ConnectToServer( HANDLE &hPipe)<br />
{<br />
LPCTSTR lpszPipename = "\\\\serverComputerName\\pipe\\Server";<br />
bool connected = false;<br />
hPipe = CreateFile( <br />
lpszPipename,
GENERIC_READ |
GENERIC_WRITE, <br />
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hPipe != INVALID_HANDLE_VALUE) <br />
{<br />
connected = true;<br />
break; <br />
}<br />
return connected;<br />
}<br />
Here the problem, the ServerApp CreateNamedPipe() and then called ConnectNamedPipe(). If there isn't a client connect to the same pipe, the ConnectNamedPipe() waits until a client get connected.
The client Application called CreateFile() to connect to the pipe the server opened,
and return was return connected = true. However in the ServerApp, ConnectNamedPipe() is still waiting for the client to connnect.
Why the ServerApp stills think there isn't a client connecting to the pipe even though the CreateFile() in the ClientApp is successfully connected to named pipe?
Thank you
|
|
|
|
|
I have an up coming project where I need to scan a map and link part of the map to a database. I am c++ and c# programmer. If there is any techology out there that is related I would like to know. I don't want to reinvent something.
|
|
|
|
|
|
Hi.
A simple question.
How could I change the fontcolor of a static control or edit box or button, etc.
For example: if I have the static control with the ID -> IDC_STATIC, what should write in InitDialog to change the fontcolor to green?.
Thank you very much.
|
|
|
|
|
Wim Summer wrote:
How could I change the fontcolor of a static control or edit box or button, etc.
Handle the WM_CTLCOLOR message of your dialog box.
Try something along the lines of:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
<code> if(pWnd->GetDlgCtrlID() == IDC_STATIC)
{
pDC->SetTextColor(RGB(0,128,0));
}</code>
return hbr;
}
Happy Programming and God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Hi.
A simple question.
How could I change the fontcolor of a static control or edit box or button, etc.
For example: if I have the static control with the ID -> IDC_STATIC what should write in InitDialog to change the fontcolor.
Thank you very much.
|
|
|
|
|