|
Super Hornet wrote: Is there any better way of running an application at windows startup?
Make it a Windows Service[^] There is a C++ Application Wizard that supplies a starter project for a Service.
led mike
|
|
|
|
|
Hi,
I'm using MFC extension dll.
I've 2 questions.
1. Why do i get exception while trying this:
char* s1 = "";
char* s2 = abc";
strcpy(s1,s2); //exception
But if i try this it works:
char s1[255];
char* s2 = abc";
strcpy(s1,s2);
Why is this so?
2. I've an exposed function BOOL _stdcall SetName(CString& name)
There is a function defined in another class but in same dll as below.
void CMyClass::Myfn(CString& str)
{
m_str = str;
}
where m_str is CString variable declared in header and initialized as
m_str = "" in CMyClass constructor.
I create an object of CMyClass and call Myfn() in SetName.
SetName is called from a vb.net application.
I get exception while assigning m_str = str in Myfn();
(This works fine if i'm calling the dll from an MFC application.)
I solved the problem by making the following changes.
m_str declaration as char m_str[255] and removed initialization from constructor.
Myfn() as
void CMyClass::Myfn(char* str)
{
strcpy(m_str,str)
}
But how did it work? Will it create problem in anyother scenario?
Thanks & Regards,
sanju
|
|
|
|
|
s1 has not enough space to write the content of s2 in it
|
|
|
|
|
For the second question (tox already answered the first): this is simply due to the fact that a CString class (yes, it is a class) is not compatible with whatever VB uses to represent a string.
|
|
|
|
|
1. sanjutvm wrote: Why is this so?
because you've only allocated one byte for s1.
2. just guessing here... tough to say based on what you've shown us. but i doubt vb.net knows anything at all about MFCs CString class. generally, when exposing functions to be called from other languages, it's best to stick to primitive types:
BOOL _stdcall SetName(const char *pName)
{
Myfn(pName);
}
|
|
|
|
|
Hi All,
Thanks for the reply.
How do I perform strcpy on two char* variables?
Thanks & Regards,
sanju.
|
|
|
|
|
you simply have to assure that the destination buffer is large enough to hold the source.
|
|
|
|
|
Hi,
Thanks for the reply.
That means i cannot simply use char* as destination in strcpy. I'll have to use char* s = new char[some value].
Thanks & Regards,
sanju.
|
|
|
|
|
correct. or, if you know your strings will always be smaller than a certain size, you can use something like:
char buf[MAX_SIZE];
strncpy(buf, inputString, MAX_SIZE-1)
|
|
|
|
|
Hi,
Thank you.
Thanks & Regards,
sanju.
|
|
|
|
|
Hello,
I need a class which I can work with a huge floating point numbers and make an operations with them like *-/+
for example: 122354554654549878987.003253265465454597 * 65465465456654564.3212154654
I need something like this http://www.codeproject.com/cpp/largenumber.asp[^] but with floating point numbers.
Is there any class like I want?
SnaidiS(Semion)
|
|
|
|
|
Why won't you use long double type?
|
|
|
|
|
a little Googling turns up a few high-precision floating point libs for C++.
|
|
|
|
|
|
it says it can handle numbers in the range: 2^16384 > x > 2^[-16383]
that's far greater than the numbers you gave in your post
|
|
|
|
|
I have problems with the files.
I added the src folder to the project like that:
Tools->Options->Projects And Solutions->VC++ Directories-> and to included files and source files.
I'll show you here the most important code:
<br />
#include "stdafx.h"<br />
#include "num.h"<br />
#include "numDlg.h"<br />
#include "stdio.h"<br />
#include "xpre.h"<br />
<br />
<br />
BOOL CnumDlg::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
<br />
CnumDlg::play();<br />
<br />
<br />
return TRUE;
}<br />
<br />
<br />
void CnumDlg::play()<br />
{<br />
struct xpr s;<br />
int i,n;<br />
<br />
s=xZero;<br />
do<br />
{<br />
scanf("%d",&n);<br />
s=xZero;<br />
for(i=0;i<=n;i++)<br />
s=xadd(s,xpr2(xOne,i),0);<br />
xprxpr(s,30);<br />
putchar('\n');<br />
}while (n>0);<br />
}<br />
I earased the most of the code-just the important there.
After I'm running the program I have the following Errors:
1>numDlg.obj : error LNK2019: unresolved external symbol _xprxpr referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2019: unresolved external symbol _xadd referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2019: unresolved external symbol _xpr2 referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2001: unresolved external symbol _xOne<br />
1>numDlg.obj : error LNK2001: unresolved external symbol _xZero<br />
1>C:\Documents and Settings\Semion Naidis\My Documents\Visual Studio 2005\Projects\num\Debug\num.exe : fatal error LNK1120: 5 unresolved externals
How can I fix that?
SnaidiS(Semion)
|
|
|
|
|
you'll need to either provide definitions for those functions, or remove the calls to them.
|
|
|
|
|
I gave a definitions for those functions here:
<br />
#include "xpre.h"<br />
#pragma once<br />
<br />
<br />
class CnumDlg : public CDialog<br />
{<br />
public:<br />
CnumDlg(CWnd* pParent = NULL);
void CnumDlg::play();<br />
struct xpr xadd (struct xpr a, struct xpr b, int k);<br />
struct xpr xpr2 (struct xpr s, int n);<br />
void xprxpr (struct xpr u, int m);<br />
I have the almost the same problem...
1>numDlg.obj : error LNK2019: unresolved external symbol "public: void __thiscall CnumDlg::xprxpr(struct xpr,int)" (?xprxpr@CnumDlg@@QAEXUxpr@@H@Z) referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2019: unresolved external symbol "public: struct xpr __thiscall CnumDlg::xadd(struct xpr,struct xpr,int)" (?xadd@CnumDlg@@QAE?AUxpr@@U2@0H@Z) referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2019: unresolved external symbol "public: struct xpr __thiscall CnumDlg::xpr2(struct xpr,int)" (?xpr2@CnumDlg@@QAE?AUxpr@@U2@H@Z) referenced in function "public: void __thiscall CnumDlg::play(void)" (?play@CnumDlg@@QAEXXZ)<br />
1>numDlg.obj : error LNK2001: unresolved external symbol _xOne
And if I'm trying to define it the xZero and xOne too(extern const struct xpr xZero, xOne, xTwo, xTen;)
I have the following errors:<br />
1>c:\documents and settings\semion naidis\my documents\visual studio 2005\projects\num\num\numdlg.h(17) : error C2071: 'CnumDlg::xZero' : illegal storage class<br />
1>c:\documents and settings\semion naidis\my documents\visual studio 2005\projects\num\num\numdlg.h(17) : error C2071: 'CnumDlg::xOne' : illegal storage class<br />
1>c:\documents and settings\semion naidis\my documents\visual studio 2005\projects\num\num\numdlg.h(17) : error C2071: 'CnumDlg::xTwo' : illegal storage class<br />
1>c:\documents and settings\semion naidis\my documents\visual studio 2005\projects\num\num\numdlg.h(17) : error C2071: 'CnumDlg::xTen' : illegal storage class
What should I do?
SnaidiS(Semion)
|
|
|
|
|
it's hard for me to say. i suggest you try to contact the authors of the class to see if they have any documentation that can help.
|
|
|
|
|
Maybe you have any other libraries like this one?
SnaidiS(Semion)
|
|
|
|
|
i don't have any libraries of this type.
try Google.
|
|
|
|
|
Hi all,
I use GetTempFileName() to create a temporary file. I fill this file with XML-Data and use ShellExecute to start Excel with my temporary file.
Now I want to delete this file again, since it was only temporary.
But...
When invoking DelteFile() directly after ShellExecute(), Excel says, that the file is not existent.
When waiting for some seconds after ShellExecute(), Execl runs well, but the file is not deleted, because Excel has it opened.
When not creating an XML-file, but a CSV-file instead, I can delete it immediately after ShellExecute()
So, how can I get rid of temporary files, that I have created in my Executable?
Juergen
|
|
|
|
|
e-DJ wrote: When invoking DelteFile() directly after ShellExecute(), Excel says, that the file is not existent.
And this surprises you?! What would you expect it to do?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I expected Execl to load the file before it is deleted. It works with CSV-files.
But XML-files seem to take more time to be opened.
I solved the problem this way, that I use OnClose() to search and delete all temp-files, that my appl has created. It works.
Juergen
|
|
|
|
|
e-DJ wrote: I expected Execl to load the file before it is deleted.
Not sure why you expected that. Unless told to do otherwise, Windows is asynchronous in nature. You have to explicitly provide synchronization constructs.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|