|
Anonymous wrote:
I put cmd.exe before the command and it did allow the process to be created, but it doesn't send the command that comes after it, because what I get back through the pipe now is:
Microsoft Windows 2000 [Version 5.00.2195]
Do you know why this is happening?
This is how cmd.exe announces itself when it starts. Try adding the "/c" switch to it. ie. "cmd.exe /c ...."
This what I do in ED for Windows (see sig) to run builtin commands. This is in ED's Tool|Build Setup which lets you run Compilers etc. and capture their output.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hi,
I have a small problem regarding CObArray..
I've created a CObArray Object and i add to
it an object of my class.. (i do it in a for loop)
obIntervalTasks.Add( new CIntervalBasedTasks( "BLABLA",
24 );
Now at some instance i try to retreive it like
CIntervalBasedTasks*& temp = (CIntervalBasedTasks*&)
obIntervalTasks.ElementAt(i);
Now i do something with my object (temp)..
and then just don't want it to be deleted from Array..
and i exit from the function..
But while my application close.. i get lot of Object
Dumps.. actually these are because of hanging pointers..
temp..
How do i handle it..
Please help
Sameer
|
|
|
|
|
I might be misunderstanding something here from your question, but it seems as though the only thing missing from your application is the for loop to spin through the CObArray and delete the referenced objects. Typically, this would be done in some cleanup-type function of the appropriate class. For example, if the CObArray is in my view class, I normally place the clean-up in OnDestroy. If it's in the document, I clean up in OnCloseDocument and so on.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hi,
I've below a small snipplet
for(int i=0;i<aintervaltasks.getsize();i++) {
="" cintervalbasedtasks*="" temp="(CIntervalBasedTasks*)" aintervaltasks.elementat(i);
="" i="" do="" some="" processing="" here
=""
}
<="" font="">
now if i delete temp then it gets
removed from the array.. I don't want that..
so how do i remove the temp.. (coz would create memory leak)
|
|
|
|
|
temp is just a pointer to an existing piece of memory. Simply don't delete it if you want to keep that piece of memory.
By creating a pointer, and assigning to that pointer a memory address, you are not creating new memory - you are just pointing to existing memory, so there is no need to call delete.
Just make sure you call delete on all the elements in the array once you have done with them
cheers,
Chris Maunder
|
|
|
|
|
I guess, this solves my problem..
but when my application exits.. it shows me
some Object Dumps. how can i come to know
which are those..
Regards
Sameer
|
|
|
|
|
Sameer Maggon wrote:
it shows me
some Object Dumps. how can i come to know
which are those..
THEY are the objects in your ObArray. You don't need to delete them when you are using them, but your REALLY want to delete them after you've finished using them.
int i = 0;
while (i < myArray.GetSize() )
{
delete myArray.GetAt( i++ );
}
myArray.RemoveAll();
cheers,
Chris Maunder
|
|
|
|
|
Sameer Maggon wrote:
now if i delete temp then it gets
removed from the array.. I don't want that..
so how do i remove the temp.. (coz would create memory leak)
1) Actually, I don't believe deleting an object removes its entry from the array. You'll need to do a RemoveAt for that to happen. Or a complete RemoveAll to dump all entries.
2) However, I don't follow your issue then. You're saying you have memory leaks because you're not freeing memory, but then say that you don't want to free memory
Simply put, you've allocated some objects in memory and placed pointers to these objects in an array (a CObArray). When you no longer need this array (such as when the containing object is being destroyed), you need to free the memory being pointed at by the array. To do that requires a simple for loop.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hi!
what is the code to enable a disabled dialog object?
Like if I want to enable IDC_RADIO1 when someone writes in IDC_EDIT1.
|
|
|
|
|
GetDlgItem(IDC_RADIO1)->EnableWindow(TRUE)
|
|
|
|
|
I need to monitor windows with certain titles, and I want to use wildcards like "*" in expressions. How can I easy add wildcard support (may * only) in my app?
I don't need complex solutions like RegExp.
Thanks.
|
|
|
|
|
You've got a very simple wildcard matching routine in snippets.org. Go to the snippets section of that website, download the .zip file (this is seemingly the only option available, the rest of the site is under construction) and search for match.doc , match.h and match.c .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, but I link to Zip I found there was broken.
ftp://ftp.snippets.org/snip9707.zip
Can you mail me these files or tell anothar solution?
Thanks again!
|
|
|
|
|
It ain't broken, I jues downloaded the .zip 5 minutes ago. Anyway, I've sent it to you by email.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Hey~
I have an MFC dialog based app with a menu bar. I've created my accelerator table and added the LoadAccelerators and TranslateAccelerator functions where appropriate and everything works fine... except... Ctrl+O will not work. Anyone have an idea why? Ctrl+X will not work either. Note, I am not intending to use Ctrl+O for the standard open file menu choice.
thanks in advance!
thundercatzlair
|
|
|
|
|
Hi,
How do i make my dlg window have focus..
I mean i have a small system tray icon.. when i press it
it displays a window.. how to i set focus on that
|
|
|
|
|
With SetForegroundWindow ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Along with Joaquín's answer, the CWnd::ShowWindow will also do the trick. I personally prefer this function as it has more options with regards to how to handle minimize, maximize, hiding, etc.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
I need to create an application which loads parts of its GUI (views) and functionality(docs) depending on the connected device type at runtime.
My first idea was to create several extension DLLs providing the neccessary functionality and load them at runtime. But this seems to be rather complicated since extension DLLs normally are
statically linked via the DLLs lib (aren't they ?). How can i overcome this ?
Any ideas ?
|
|
|
|
|
Use dynamic linking on your Dlls!! see MSDN.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Dynamic linking, sure ... but tell me how , GetProcAddress works only for plain functions, not classes or objects
|
|
|
|
|
Make a signature in every dll. I.e. a minimun set of exported functions. In your case, assuming you are using MDI, it might look like
CMultiDocTemplate* __cdecl GetDLLDocTemplate()
{
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_CHARTDLLTYPE,
RUNTIME_CLASS(CDLLDoc),
RUNTIME_CLASS(CDLLFrameWnd),
RUNTIME_CLASS(CDLLView));
return pDocTemplate;
} I guess this will work no mather what type of DLL you are using, since it doesn't export any classes.
|
|
|
|
|
Use your imagination a little, have the function you export return a class/struct.
|
|
|
|
|
My artical on this subject shows how it can be done:
http://www.codeproject.com/docview/docviewfromdll.asp
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|