|
vote 5 for gray man.
|
|
|
|
|
I really cannot understand voting down, this time.
CLSID of an existing COM interface should NEVER change. Like the interface itself.
Anyway, thank you friend.
(BTW Why gray man?)
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]
|
|
|
|
|
I think 1 was of a gold member because your rate is 3 if it was of a bronze member now it was 3.67(of course its my mind ) and thats right never changed and why gray 1=gray man and 5=red man ).
|
|
|
|
|
My vote too, but the score didn't go way too much up as expected. Sad buggers vote down for no reason.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Visual C++ MVP
|
|
|
|
|
Of course, but you haven't supplied anywhere near the amount of information for us to help. For example, what framework did you use (if any) to make the DLL?
Steve
|
|
|
|
|
this is simple sdk(not MFC) com dll.
Rajesh
|
|
|
|
|
How do I convert from std::string to char* in C++?
|
|
|
|
|
std::string s = "Hello World";
char* psz = s.c_str();
|
|
|
|
|
I followed the same method. But the following code:
std::string path = dtCore::GetDeltaRootPath();
const char* exeroot = path.c_str();
strcat(path,"/");
strcat(path,"CharacterAnimation.exe");
result = system(path);
return true;
gives me the following errors:
error C2664: 'strcat' : cannot convert parameter 1 from 'std::string' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
.\GUI.cpp(195) : error C2664: 'strcat' : cannot convert parameter 1 from 'std::string' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
.\GUI.cpp(196) : error C2664: 'system' : cannot convert parameter 1 from 'std::string' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
How do I resolve?
|
|
|
|
|
why are you using path instead of exeroot you just allocated ?
it's obvious you don't read error messages, or you don't understand what you're doing...
check your code again.
std::string path = dtCore::GetDeltaRootPath();
const char* exeroot = path.c_str();
strcat(exeroot, "/");
strcat(exeroot, "CharacterAnimation.exe");
result = <font color="red">system</font>(exeroot);
return <font color="red">true</font>;
BTW, you seem not to have takenn in account my previous remarks...
|
|
|
|
|
Now this line shows:
char* exeroot = path.c_str();
the following error.
error C2440: 'initializing' : cannot convert from 'const char *' to 'char *'
|
|
|
|
|
T.RATHA KRISHNAN wrote: char* exeroot = path.c_str();
add const then, as std::string::c_str() returns const char*
|
|
|
|
|
I think you'll get buffer overruns that way.
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]
|
|
|
|
|
That's assuming you cast away the const s so it even compiles.
Steve
|
|
|
|
|
Good point indeed.
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]
|
|
|
|
|
toxcct wrote: const char* exeroot = path.c_str();
strcat(exeroot, "/");
strcat(exeroot, "CharacterAnimation.exe");
Bad advice. The buffer returned from c_str is const and thus can't be modified. And it's wrong to cast away the const as it's const for a reason: the buffer used by a std::string need not be contiguous memory. If this is the case calling c_str makes a temporary buffer and copies the non-contiguous memory blocks into one contiguous memory block for you. It is not required to copy the blocks back. Also your code is in serious danger of causing a buffer overrun (if you made it compile by casting away the const ): how do you know how big the buffer is?
Anyway the correct way is simpler, safe, works, is portable and requires no casts:
std::string path = dtCore::GetDeltaRootPath();
path += "/CharacterAnimation.exe";
system(path.c_str());
Steve
|
|
|
|
|
You are sending strcat() the wrong param type i think.
std::string path = dtCore::GetDeltaRootPath();
const char* exeroot = path.c_str();
char* StrToCat = path.c_str();
strcat(StrToCat,"/");
strcat(StrToCat,","CharacterAnimation.exe");
etc..
|
|
|
|
|
Buffer overrun along the horizon.
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]
|
|
|
|
|
absolutely, but i only meant to identify the problem a lil more clearly
|
|
|
|
|
|
T.RATHA KRISHNAN wrote: I followed the same method. But the following code:
Nope. You got it wrongly.
T.RATHA KRISHNAN wrote: std::string path = dtCore::GetDeltaRootPath();
const char* exeroot = path.c_str();
strcat(path,"/");
strcat(path,"CharacterAnimation.exe");
result = system(path);
return true;
change to
std::string path = dtCore::GetDeltaRootPath();
path +="/";
path +="CharacterAnimation.exe";
result = system(path.c_str());
return true;
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]
|
|
|
|
|
Thanks a lot. I resolved the errors. But now my problem is: the variable path contains "Program Files". Compiler takes only Program leaving the space and after that. So the console displays an error: "C:\Program" is not recognized as an internal or external command,operable program or batch file. What to do?
|
|
|
|
|
F*CK, you don't listen to me.
if you were using ShellExecute, that wouldn't have happened.
use quotes ( " " ) around your string (within the string I mean), or use ShellExecute
|
|
|
|
|
I don't understand this:(with in the string). My string definition is:
path += "/";
path += "CharacterAnimation.exe";
result = system(path.c_str());
Where should I put double quotes?
|
|
|
|
|
god, do you understand this : use ShellExecute ?????
::ShellExecuteA(NULL, "open", path.c_str(), NULL, NULL, SW_NORMAL);
|
|
|
|