|
Okay, this seems to do it just as well:
template <class clType>
class classA
{
public:
classA (int somevalue);
void wasteTime ();
private:
clType classInstance;
};
class classB
{
public:
classB () { };
classB (int somevalue);
int something;
};
classB::classB (int somevalue)
{
something = somevalue;
}
template <class clType> classA<clType>::classA (int somevalue) : classInstance (somevalue)
{
}
template <class clType> void classA<clType>::wasteTime ()
{
printf ("Hey, how about a %d?", classBInstanceCopy.something);
}
void main ()
{
classB myInstance;
classA<classB> myClass (myInstance);
myClass.wasteTime ();
}
Looks good? Alright! Thanks for the hint!
Tilli
|
|
|
|
|
|
I want to add some documentation to my
program. Something where they can click
Here/Learn More and it just talks about
various topics.
Any one know of a simple demo project
that would do this and that would work
on all operating systems? Please let me
know.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Sir, If some application running on a PC trying to connect outside word, then how can we know about that. I want to keep watch on all outgoing connections made by all the application. Help me if you can.
C.R.Naik
|
|
|
|
|
Hmm, this seems to be kinda my area to watch. Although my suggestions have nothing to do with coding. There are a few programs online that you can download that will do pretty much what your asking for. I think one such program was called NetWatcher. Perhaps a search on Yahoo, Google, or some other search engine using the keywords, "Net Monitor, Net watcher, IPX logger, Connection watcher" or some similiar keyword might dredge up some good results.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Can any one give me a hand on above
thx in advance
|
|
|
|
|
One solution is Winsock. Communicate directly with to server via socket.
Kuphryn
|
|
|
|
|
hi,
i want to know how costly is it to create fonts,pens etc and u know, selecting and destroying every time, say in ondraw.
My problem is this(with font only)
I have to adjust the font size for the names of somethings which will be displayed in resiable boxes.the names should be appropriately sized according the box size.
any help
Raja huus
posted once.no replies
|
|
|
|
|
What do you mean with how much it cost?
How much memory it takes?
If so, it depends on how much GDI you do...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
i mean the speed of such a program that has to constantly create different sized fonts ...any easier way
|
|
|
|
|
This may sound stupid, but here we go anyways. Let's say I have 2 applications. (Prog1 and Prog2) What I want to do, is have Prog1 run Prog2, then periodically check to see if Prog2 is still running. Obviously I'll need a timer event to do this, but I don't know how to start Prog2, or see if it's still running. If you can tell me that much, I can do the rest, and will be very gratefull. NOTE: I do know how to start Prog2 using WinExec() and ShellExecute(), but I have a sneaky suspicion that I'll need to use CreateProcess(), of which I know nothing.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Magius96 wrote:
This may sound stupid,
I know that feeling.
How about giving Prog2 a title and then
bool bRet = false;
HWND hWindow;
hWindow = ::FindWindow(NULL, _T("Prog2"));
if(hWindow!=NULL) bRet = true;
Or another way might be to get Prog2 to create a named Mutex that Prog1 checks for.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
Thanks for the advice, but I can't use the first suggestion, because Prog2 is actually a dos program, and several copies of it could be running at once. I also can't use the 2nd suggestion, because Prog2 is already compiled.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Magius96 wrote:
I also can't use the 2nd suggestion, because Prog2 is already compiled
Yes you can. He suggested you'd modify Prog1 to wait for Prog2. Basically you CreateProcess(Prog2) and WaitForSingleObject() on the process handle.
--
This space for rent.
|
|
|
|
|
Doh. Disregard my previous post. I thought you were referring to Takas suggestion.
--
This space for rent.
|
|
|
|
|
There's any number of ways you can do this but yes, CreateProcess() is probably the best. It will give you a HANDLE that represents the process that you can use to test if it is still running. You won't even need a timer - call WaitForSingleObject() with an INFINITE timeout and it will block until the process finishes.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Your answer seems to be closer to what I'm looking for, in that it sounds like I'd be checking for Prog2 by it's process id. That is precisely what I'm hoping for. The problem I'm having is that the book I've learned VC++ from doesn't give much(if any) information regarding CreateProcess() or WaitForSingleObject(). By typing them into my project, I can see what arguments they require, but I don't fully understand them. Guess I need a more advanced book than "Sam's Teach Yourself Visual C++ 6 in 21 Days", eh? (whew, long title, don't hold your breath while saying it)
--EDIT--
Actually, now that I look at it. I do understand how to use WaitForSingleObject(), but I'm still confused on CreateProcess(). Oh, well, give me a few days, and I might puzzle that one out too.
--END EDIT--
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Yep. You need "Teach Yourself VC in 90 days", at least!
Sounds like you don't have the MSDN - you can look things up online here: msdn.microsoft.co[^]m (use the search box in the top-left corner)
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Used to have the full MSDN, but lost the disks, and had to reinstall my system at some point in the past. Really do miss em though.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
After doing some rather deep digging here in the forums, I've found the following snippet:
STARTUPINFO siInfo;
PROCESS_INFORMATION piInfo;
siInfo.cb = sizeof(STARTUPINFO);
siInfo.lpReserved = 0;
siInfo.lpDesktop = NULL;
siInfo.lpTitle = NULL;
siInfo.dwFlags = STARTF_USESHOWWINDOW;
siInfo.cbReserved2 = 0;
siInfo.lpReserved2 = NULL;
CreateProcess("F:\\path\\program.exe", "", NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, "F:\\path\\", &siInfo, &piInfo);
Now, you were saying to pass the handle to WaitForSingleObject(), but which of the above is the handle?
(plus, i'm still slightly confused on what all that is, but if it works, great)
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Consulting my MSDN ( ), CreateProcess() returns the following in piInfo:
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
where hProcess is the handle (i.e. an internal system cookie, if you like) for the process and hThread, a handle for the process's primary thread. The ID's are unique numbers for the process and thread but are not terribly useful.
So, you pass the hProcess in to WaitForSingleObject(). If you specify a timeout of INFINITE, this call will block until the process ends. Or if you use 0, it will do a quick check to see if the process is alive at that moment. Or you can pass in a number of milliseconds - the call will wait for that amount of time for the process to finish and return a value indicating whether it did or not.
Don't forget to call CloseHandle() for both these handles when you're done otherwise you'll get a leak.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Your answer, although informational, was still a bit cryptic. However, you did give me enough information to work with, that I could use msdn.microsoft.com to find the rest. This little bit of sample code, along with your advice, lead me to just what I was looking for.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
"MyChildProcess", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
ErrorExit( "CreateProcess failed." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Magius96 wrote:
Your answer, although informational, was still a bit cryptic.
Well, we don't want to make it *too* easy for ya!
What you've got looks pretty spot on.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Ok, now that I've got that much working, perhaps you'd entertain me to give me a suggestion(tease me more like it), on how to convert a CString to char. I'm passing command line arguments from a user interface, but the darn compiler is complaining that they must be char's and not CString class. My luck eh? Almost complete, and I throw a wrench into the darn thing.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Cast it it a (LPCTSTR). Or look at GetBuffer().
Hmmm... Not cryptic enough, by far.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|