|
If i remember correctly previously you were asking how to convert an MDI application to Dialog
and now you want to convert a dialog based app to a service.
Why don't you create the app according to your needs??
It is simply waste of your own time..
Regards,
Sandip.
|
|
|
|
|
yes you are 100% right..I was asking.
Now i want to start a application when system is boot.And i have a code in dailog which is working fine.So can you tell me in which i go to do that?
Plz help me
|
|
|
|
|
Hello everyone,
Here is the related x64 assembly code generated for my application. I run in on Windows Server 2003 x64. It is just a simple member method call on member foo, and the member method accepts a single input Bool parameter.
Here is the code.
My question is, on x64 it should be rcx used for this pointer, and rdx should be used for the actual parameter m_bMandatory? But what is the function of the statement -- "mov r8d,r13d". Please correct me if I am wrong.
foo.Render(m_bMandatory);
000000001AC96E2F lea rdx,[rsi+58h]
000000001AC96E33 mov r8d,r13d
000000001AC96E36 lea rcx,[foo]
000000001AC96E3B call CFoo::RenderPackage (1AC96AC4h)
thanks in advance,
George
|
|
|
|
|
Hi,
I am having a really hard with named pipes async. I/O
I have a Dos Console Server and a WIN32 GUI client
I am running both the Dos Console app and the WIN32 app
under the Visual Studio Debugger (2 instances)
in The DOS console server I Do the ConnectNamed pipe Then CreateProcess of the Win32 Gui
When in the WIN32 GUI I do I CreateFile The I enter the Windows Message Loop
Back in the Dos Console program I Do a ConnectNamedpipe
When the User makes a Selection in the GUI
I display a Modal DialogBox the information I need is in the Dos Console
in The DialogBox procedure I do a CreateThread
e.g.
/* Create a Thread to Wait For The Async I/O */
thread_handle = CreateThread(NULL,
NULL,
IO_FUNC,
io_parms,
NULL,
NULL);
The Following is my Code in the Thread
return_code = WriteFileEx(filehdl,
test_message,
8,
&my_verlapped,
write_rtn);
if (return_code == 0)
errcd = GetLastError();
while (SleepEx(INFINITE,TRUE) != WAIT_IO_COMPLETION); // Wait for I/O
The I/O competion routine is a Exported Function in the Dos Console process
it never gets control
The return code from all WIN32 apis are all OK
Any IDEA why my iocompletion routine doesn't get control ???
Thankx
|
|
|
|
|
My Dos console consists mainly of DLL
seeems like the I/O compeltion routine cann't reside in a DLL
Does anyone know if the Overlapped structure / hEvent can reside in a DLL
|
|
|
|
|
Hello everyone,
Just want to confirm a basic concept when reading a couple of documents about diamond problem and virtual inheritance.
1. Diamond problem covers both ambiguity methods and data member variable?
2. Virtual inheritance only solves ambiguity data member issue (making data member one copy)?
3. So, it is not correct to say virtual inheritance solves diamond problem 100% since ambiguity member methods is not covered and solved?
thanks in advance,
George
|
|
|
|
|
Hi,
Try the following code it might help you:
==========================================================================
#include "iostream.h"
#include "stdio.h"
class A
{
public:
int m_nAInt;
A(int n = 1):m_nAInt(n)
{
cout << "Class A Constructor called" << endl;
}
Display()
{
cout << "A::Display()" << endl;
}
};
class B: public virtual A
{
public:
B()
{
cout << "Class B Constructor called" << endl;
}
};
class C: public virtual A
{
public:
C()
{
cout << "Class C Constructor called" << endl;
}
};
class D: public B, C
{
public:
D()
{
cout << "Class D Constructor called" << endl;
}
};
int main(int argc, char* argv[])
{
D dObj;
dObj.Display();
return 0;
}
==========================================================================
|
|
|
|
|
What is the issue, tony_udz? Could you clarify please?
You code runs ok without any compile/build warning/errors.
Here is the output.
Class A Constructor called
Class B Constructor called
Class C Constructor called
Class D Constructor called
A::Display()
regards,
George
|
|
|
|
|
Hi George,
George_George wrote: You code runs ok without any compile/build warning/errors.
That means virtual resolved methods as well as data member ambiguity so that does not clear your doubt.
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Thanks, Sandip!
So, you mean virtual inheritance makes one copy of both methods and data?
regards,
George
|
|
|
|
|
George_George wrote: So, you mean virtual inheritance makes one copy of both methods and data?
Yes unless you do not override the common method in both derived classes.
In above case if you override Display method in both derived classes you will get ambiguity error.
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
I have tried that when overriding in both classes, there will be compile error regarding the ambiguity issue. But when overriding only in one class, there is no compile error regarding the ambiguity issue, why??
regards,
George
|
|
|
|
|
George_George wrote: But when overriding only in one class, there is no compile error regarding the ambiguity issue, why??
In that case i think preference is given to overridden method.
and you can always use scope resolution operator to execute desired method
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
"In that case i think preference is given to overridden method." -- you mean when calling D.Display, there are two choices,
1. D::B::Display;
2. D::C::A::Display.
But since (1) is "more" overridden than (2), (1) is preferred, but if we derive Display in both B and C, D will have no choice and there will be ambiguity compile error?
regards,
George
|
|
|
|
|
George_George wrote: "In that case i think preference is given to overridden method." -- you mean when calling D.Display, there are two choices,
1. D::B::Display;
2. D::C::A::Display.
But since (1) is "more" overridden than (2), (1) is preferred,
Yes from the behavior it seems like that.
Even i did not come across any documents that states above behavior.
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
Here is what I learned from you -- virtual inheritance solves both member method and member data issue -- so we can say virtual inheritance solves all diamond problem issues (both ambiguity member method and data member). Could you review and confirm my understanding now is correct please?
regards,
George
|
|
|
|
|
Yes unless there is no overriding of methods from the common ancestor as i said earlier.
Regards,
Sandip.
|
|
|
|
|
I agree, thanks Sandip!
regards,
George
|
|
|
|
|
I have some queries here..
1. By making the inheritance virtual how the ambiguity is actually resolved?
I mean, what this virtual inheritance does internally? Does it create another vptr of another vtable?
if it is so how does the new vtable looks like??
2. And as the diamond problem says that there is an ambiguity that whether D will have path
A->B->D
or
A->C->D
A
/ \
B C
\ /
D
So after removing ambiguity which path is taken?
|
|
|
|
|
Hi,
Is there any memory leak in the following code? I cannot see any one. But bound checker telling there is a leak? Please advice me. Thanks in advance.
class test<br />
{<br />
char* m_name;<br />
public:<br />
test():m_name(NULL)<br />
{}<br />
void Set(const char* name)<br />
{<br />
<br />
if(name!=NULL && strlen(name))<br />
{<br />
m_name = new char[strlen(name)+1];<br />
strcpy(m_name,name);<br />
}<br />
else<br />
delete [] m_name;<br />
}<br />
~test()<br />
{<br />
Set(NULL);<br />
}<br />
void display()<br />
{<br />
cout<<m_name<<endl;<br />
}<br />
};<br />
int main(int argc, char* argv[])<br />
{ test tst;<br />
tst.Set("123456");<br />
tst.display(); <br />
return 0;<br />
}<br />
|
|
|
|
|
SRKSHOME wrote: void Set(const char* name)
{
if(name!=NULL && strlen(name))
{
m_name = new char[strlen(name)+1];
strcpy(m_name,name);
}
else
delete [] m_name;
}
Assuming name is valid
On first call to Set method, m_name is NULL and you allocate memory to it.
On second call to Set method, m_name had valid allocated memory from first call. But prior to allocating new memory, the previous allocated memory is not deallocated
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks for your reply. But if you look at the main function I have called set("123456"). I have never called set(..) for second time. Second time this functin is called from destructor and NULL is passed to Set(). Hence I cannot see memory leak here. Please correct me if I am wrong.
|
|
|
|
|
I see the above as obvious memory leak in code. Also Sarath (in the reply below) pointed to the same problem. Try fixing the problem and then see if there is still memory leak.
You may also want to re-think about how m_name is deallocated when object lifetime ends.
modified 21-Apr-21 21:01pm.
|
|
|
|
|
The program will be having memory leak, if you call set twice. You can rewrite the code better.
class test
{
char* m_name;
public:
test():m_name(NULL)
{}
void Set(const char* name)
{
if( name == NULL || 0 == strlen(name))
return;
if( m_name )
delete []m_name;
m_name = new char[strlen(name)+1];
strcpy(m_name,name);
}
~test()
{
if( m_name )
delete [] m_name;
}
void display()
{
cout<<m_name<<endl;
}
};
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks for your better code reply.
|
|
|
|