|
Hi
I've now got a piece of code that updates an excel spreadsheet on my desktop. I was impressed - thanks to all the CP article writers that made this possible.
Anyway, I can see a bank of 10 users across from my desk who also want my code to update their spreadsheets - is this where DCOM comes in? I would install a DCOM component on all their clients and get my app to talk to the DCOM which in turn would update the local spreadsheet?
Any other 'simple' ideas would be much appreciated as I have no DCOM experience (or much COM come to think of it!!)
See if anybody can answer before David Crow!
Cheers
Angel
******************************************************
Why prolong the agony, all men must die - Roger Waters
|
|
|
|
|
Can your app be run locally on each machine?
Introducing DCOM would end up giving you more headaches than are good for you Especially if you don't know a lot about COM in the first place.
Have a read of some of these pages[^] to get a flavour of what DCOM is.
Michael
CP Blog [^]
|
|
|
|
|
I am trying to create an object of a class(say class1) in a member function of another class(say class2) on the heap. The trouble is it is asserting on that and i cannot proceed further. If I create a normal object(on stack) and call a member function of class1, the function is unable to access the member variables of its own class(class1). It's making me go nuts. I had earlier tested class1 for correctness but now that it is part of this whole application, I don't know what has happened. Please help me. It is urgent.
|
|
|
|
|
AmorphousP wrote:
The trouble is it is asserting on that...
On what? Show us some relevant code.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
CDns* DnsCl = new CDns;
This is the part where I am creating the object on the heap in a function of another class, CDnsThread. This is the code that asserts.
CDns* DnsCl;
This is the part when it is created on the stack. It doesn't assert but now when I call a public member fuction of the CDns class like
DnsCl->GetSMTPAddress(domain);
the code inside the GetSMTPAddress() function can't access it's own member variables. I tried debugging it and found that the constructor works fine because all the initialization work I do happens correctly. But the first line inside the GetSMTPAddress() function
if (SockStatus = INVALID_SOCKET)<br />
error handling code...
causes an 'access violation'. This same thing had worked very well some time back when I had tested this module. But now as a part of an application, it's causing troubles. I hope u r able to help.
Thanx
|
|
|
|
|
CDns* DnsCl = new CDns;
where does it assert ? check what you do in the constructor...
CDns* DnsCl;
this is not allocated at best, the pointer will be 0 , at worse, anything ... but DnsCl is invalid ... you need to new it; or remove the * .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Tried removing the *. Didn't work either. Asserted on the Create call only.
|
|
|
|
|
AmorphousP wrote:
CDns* DnsCl = new CDns;
This is the part where I am creating the object on the heap in a function of another class, CDnsThread. This is the code that asserts.
What line of what file is firing the assertion? Have you set a breakpoint in the constructor of CDns and stepped through it?
AmorphousP wrote:
CDns* DnsCl;
This is the part when it is created on the stack. It doesn't assert but now when I call a public member fuction of the CDns class like
DnsCl->GetSMTPAddress(domain);
...
causes an 'access violation'.
I'm not surprised. How is this working without the new operator being called?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Actually the object is getting created dynamically now and I tried stepping through the constructor of CDns.
DnsSocket = new CSocket;<br />
SockStatus = TRUE;<br />
if (DnsSocket)<br />
{<br />
if (!DnsSocket->Create(0, SOCK_DGRAM, 0))
It's asserting on Create. It's here that it gives an access violation. The ASSERT that fires it is
ASSERT(CAsyncSocket::LookupHandle(hSocket, bDead) == NULL);
in the file sockcore.cpp
DavidCrow wrote:
AmorphousP wrote:
CDns* DnsCl;
This is the part when it is created on the stack. It doesn't assert but now when I call a public member fuction of the CDns class like
DnsCl->GetSMTPAddress(domain);
...
causes an 'access violation'.
I'm not surprised. How is this working without the new operator being called?
It was actually a desperate attempt to get the work done although wasn't a very logical choice.
|
|
|
|
|
AmorphousP wrote:
DnsSocket = new CSocket;
What do u do before this line ? You must be calling Create() before the socket object is initialized.
Dharani Babu S
|
|
|
|
|
I actually solved the problem. The trouble was that this code (DnsSocket = new CSocket ) is written inside a new secondary thread. As such there was no initialization code for winsock in the thread and that's why the code was asserting on DnsSocket->Create() . Now it works fine
-----------------------------
Nobody got anywhere in this world by simply being content.
|
|
|
|
|
Hi!
I recently stumbled over this interesting phenomenon using abstract member functions:
The situation is this: We have an abstract base class that defines an interface. In the constructor of the base, a specific implementation dependent task needs to be carried out, so an abstract
member function is invoked in the constructor. The behaviour of this member function is defined by derived classes.
If no function body is provided for this abstract function in the base class, a linker error occurs (unresolved symbol). If we provide an empty body, in the base, everything links fine and the vtable
lookup correctly resolves the implementation of the deriving class.
The question is this: If the abstract function is resolved at run-time anyway, through use of vtables, why give me a compile-time error if I don't provide a body that will, due to it being an abstract
function, never be used in the first place?!
Is this a Microsoft specific behaviour bug/"feature", or is this standard ISO behaviour?
I compiled this using MS VS .NET 2003
Thanks for any thoughts about this.
Nick
Here is some exaple code for you to check it out:
<br />
#include <stdio.h><br />
class base<br />
{<br />
public:<br />
base()<br />
{<br />
abstractFunction();<br />
}<br />
virtual ~base() {};<br />
<br />
<br />
virtual void abstractFunction() = 0 ;<br />
};<br />
<br />
class derived : public base<br />
{<br />
public:<br />
derived() {};<br />
virtual ~derived() {};<br />
<br />
void abstractFunction()<br />
{<br />
printf("works\n");<br />
}<br />
} testInstance;
This code should print "works" to the console, since the
As soon as you uncomment the function body of base::abstractFunction(), everything will link fine and work as expected.
|
|
|
|
|
You cannot call a virtual function of a derived class from a base class constructor. This is due to the order of construction. Base classes are built first so there is no vtable pointer available to call the correct function in the derived class, which is yet to be constructed.
You need the function body as the virtual call compiles to the base class member function not the derived class one.
You need a two stage construction method to handle what you need to do.
x = new drieved;
x.Initialise();
Where the initialise function calls the correct virtual functions once the object is fully constructed.
If you vote me down, my score will only get lower
|
|
|
|
|
Ah, I see.
That escaped my attention. Quite obvious though, come to think of it. (->silly me)
So the fact that my example code works OK is only by chance and not a regular case and more complicated classes or a release version compile might produce unpredictable results.
Thanks for the comment.
Nick
|
|
|
|
|
|
Hi,
Is it possible to "peek" stdin (i.e. check if any data is available) for a Win32 "kind of" console application?
Problem: A thread has to read stdin, but needs to react on an event
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
See if GetStdHandle() , and ReadConsoleInput() or ReadFile() are of any help.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi, I just made a program and I put a button in the dialog and called it IDAbout I need to get it so that when this button is clicked it open up another Dialog that I have made called IDD_ABOUTBOX. Can any body please help me write a code for the button so that it opens up the about box?
I am using MFC Dialog based project.
Thanks in advance.
|
|
|
|
|
Have you created a class for the IDD_ABOUTBOX dialog?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Ok, have you used ClassWizard to create a handler function for the clicking of the button?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes I have. Ijust dont know the script to put into:
void CMizfarsProgramstringtestingDlg::OnAbout()
{
// I need the code to put here to get it to open IDD_ABOUTBOX
}
To link it to the About Box.
Thanks
|
|
|
|
|
Construct an instance of the second dialog and call its DoModal() method.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
can you dum it down a bit please. I am only starting out with programming so i dont know much. Please can you explain it as if you were explaining to layman.
|
|
|
|
|
Buyer1 wrote:
can you dum it down a bit please.
I much prefer the phrase "less experienced."
Not knowing what name you gave your dialog class, I can only give you an approximation.
void CMizfarsProgramstringtestingDlg::OnAbout()
{
CMyOtherDlg dlg;
dlg.DoModal();
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|