|
no,i didn't find anything useful for me in your article.Thanks anyway...
|
|
|
|
|
Hey all,
I got a little problem, I'm using VS2008 and built a console MFC app all was well, it works and does excactly what I need but....
I was testing the application on a clean Windows XP SP3 with IE7. But the application failed to run, I realised this was due to the common runtime, since VC9 runtimes are not installed on the test PC. We do not want to have to install the runtimes, so I rebuilt the exe with /clr but all I get is 0xc000135 when I try to run it, I have tried various methods to get round this. The only way I can get it to work is to have the MFC and CLR dlls in the same folder using private assemblies in the manifest.
I want to avoid this, if possible? anyone help?
Thanks in advance!
|
|
|
|
|
/clr is for enabling using managed code from C++ and has got nothing to do with your problem. As far as I know there ase only 3 says to ship the CRT and MFC DLL's.
1. Install VC++ redistributable package on client machine.
2. Statically link to both CRT and MFC libraries.
3. Install CRT and MFC DLL's as private assembly.
Static linking typically create problems if the executable depends on other 3rd party DLL's which use dynamic version of CRT or MFC.
For the private assembly follow in instruction at http://www.codeproject.com/KB/cpp/vcredists_x86.aspx[^], there is a section on "Install a private assembly".
-Saurabh
|
|
|
|
|
Ah I thought /clr was for CRT...my noobish mistake
Thanks for the help I'll linking CRT along with my already Static linked MFC
|
|
|
|
|
Got it working!! yeah!!
Thanks for your help!
I have origonally started with a shared MFC link and wanted to change it, I tried looking at /MT before but the compiler complained so I thought I was doing something wrong.
In the end it was all because I started the project as a shared MFC link and used the _AFKDLL preprocessor defination. Removing _AFXDLL and chaning to a Static MFC link and using /MT the exe compiled and works now.
Well atleast I learned more about the IDE and how things are compiled and linked.
|
|
|
|
|
Did you try linking to the MFC Dll's statically, but this would increase the size of your application considerably.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi, Is there any memory leak in the below code... if there are how can resoleve it.thaks..
class test<br />
{<br />
int a;<br />
public:<br />
test(int i):a(i){}<br />
void diplay(test* tst)<br />
{<br />
int i = tst->a+30;<br />
cout<<i<<endl;<br />
}<br />
~test(){}<br />
};<br />
<br />
int main()<br />
{<br />
<br />
<br />
test* test1;<br />
test1->(new test(20));
<br />
return 0;<br />
}<br />
|
|
|
|
|
I've never seen something written like test1->(new test(20)); //debugger telling me here is memory leak. before... what do you expect this line to do???
|
|
|
|
|
sorry..Small typo error..it suppose to be test1->display(new test(30)).It will create pointer to that object while passing as a argument. It may be reducing lines of codes. But my question is is it good practice?
modified on Monday, September 29, 2008 3:39 AM
|
|
|
|
|
well in that case you definitely do have a memory leak, as you are allocating memory with new , but you never called delete on it, and have no way to, because it was never assigned to a variable, but instead simply passed directly into a function.
What you should do is allocate memory to a variable using new first, and then pass that variable to the function, like so;
test * theVar = NULL;
theVar = new test(30);
test1->display(theVar);
Then when you are done with theVar call delete on it and assign NULL to it;
delete theVar;
theVar = NULL;
And then you have no memory leak.
Another thing to keep in mind is to check whether or not theVar is NULL before you use it, so back in my original code snippet you would change it to something like this;
test * theVar = NULL;
theVar = new test(30);
if(theVar != NULL)
{
test1->display(theVar);
}
else
{
}
|
|
|
|
|
|
it is a litle crappy.
better:
test1 = new test(20);
//at end
delete test1;
Greetings from Germany
|
|
|
|
|
SRKSHOME wrote: test1->(new test(20));
That is because you are doing memory allocation with new, and you have no way of deleting the pointer to that memory location, since you don't have a variable to delete. Try using a pointer variable and then you can free the memory it points to
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
There are two bugs in this program:
1. test1->(new test(20)); // This is incorrect. Perhaps you mean test1->display(new test(20));
2. You are using test1 without allocating memory for it.
You can try something like this:
test* test1 = new test;
test* test2 = new test;
test1->display(test2);
delete test1;
delete test2;
Or
test test1;<br />
test test2;<br />
test1.display(&test2);
-Saurabh
|
|
|
|
|
Hi All
I am new in vc++.I have a problem to get length of array.Plz help me
|
|
|
|
|
|
Thanks for reply but it's not working
i have a CString store[100];,CString File; and int cou=0;. And i use store[cou]=File. And i want to get Size of store[cou].Plz help me
|
|
|
|
|
|
CArray or user defined array??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
|
do you want the size of the array in bytes, or the number of elements in the array?
if you want the size in bytes, use the sizeof() like so;
int size_in_bytes;
int theArray[20];
size_in_bytes = sizeof(theArray);
|
|
|
|
|
Hi,
Dont use user defined array in this case. You better use CStringArray.
Then you no need to calculate the size of the array. This class is having a member function int GetSize() to get the size of the array.
The price of anything is the amount of life you exchange for it.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
please read at first the docs about the used obejcts carefully. Often there are tiny little helper as .length or .GetLength to solve such problems. (And use the search box in top of this site a lot)
Greetings from Germany
|
|
|
|
|
What kind of array are you using? Could you please post array declaration?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|