|
|
I was using Afx earlier on in my project!
But since I hate MFC, I rewrote the segments that were using the CFile and replace them with WriteFile.
However when I decided to remove the Afx.h header.
It gave me an error during recompilation.
1>main.obj : error LNK2001: unresolved external symbol __imp__SHStrDupW@8
1>C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Win32\Release\Win32.exe : fatal error LNK1120: 1 unresolved externals
Since the SH reminded me of the shell APIs I looked up the function.
SH String Duplicate, which I'm not using at all in my code.
|
|
|
|
|
maybe the 'depends' MS tool will tell you what your dependancies actually are - obviously something in your code or being used by your code is using this
'g'
|
|
|
|
|
Well I got my hands on the application!
But I don't know where to start.
Tried profiling, but it is halted by these errors.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
|
|
|
|
|
It's a link error, so everything compiled correctly (you're including the correct header). The linker can't find the definition of the function SHStrDup ; looks like you not linking to the correct import library. A quick look at the docmentation shows that you should be linking to "Shlwapi.lib". Either add it to the list of libraries you're linking to or add the following line somewhere:
#pragma comment(lib, "Shlwapi.lib")
Steve
|
|
|
|
|
hi,
I need to do language localization using XML in VC++ (MFC).
I need to do mapping using XML file and i need to scan the XML file for the desired language, so that my output would be in my desired language.
I have no idea, how to go about it.
Please Support.
Thanks,
Punyah
|
|
|
|
|
You know that you need C++ and XML but have no idea on how to do it? That's funny, IMHO.
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]
|
|
|
|
|
Yes, because got some guidelines from my manager that it will be done using XML and the project is already in MFC vc++. so, will you please help, if u can.
Thanks.
|
|
|
|
|
Well, you may create XML files similar to string tables, with each language you support having it's own (or more than one) XML table.
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]
|
|
|
|
|
A better approach that xml is explained in this article:
Resource DLLs and Language Selection Menu[^]
If nothing else, reading that article will help you understand some of your challenges.
With xml, you'll have to parse it, and change the text in every element in any dialog manually... Your code will be brittle.
I hope your manager has some cunning plan in mind. Or has he just heard that xml is a good storage method? And likes buzzwords?
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
DWORD cchData = MAX_VALUE_NAME;
char* achData;
if (!RegGetValue(hKey, NULL, L"Left", RRF_RT_REG_SZ, NULL, achData, &cchData))
xPos = atoi(achData);
Only getting 1 character! The first on the far left.
|
|
|
|
|
you have to provide a buffer that's big enough to hold the data from RegGetValue. an uninitialized pointer isn't enough.
|
|
|
|
|
tried
char achData[MAX_VALUE_NAME];
But still only one character!
|
|
|
|
|
How about using TCHAR instead of char. Sounds like your program is being compiled using unicode.
TCHAR achData[MAX_VALUE_NAME];
Kelly Herald
Software Developer
|
|
|
|
|
Hi, its been a while since I've posted here .
I've come back to C++ after doing quite a lot of scripting in Python though Scripting is still a passion of mine but enough about scripting.
I read an article about Memory Management in C++ the other day and some one wrote the code about borrowing a object through a reference even though it was created on the free store.
I'm mixed up about the various syntaxes heres some examples of code im mixed up with.
Robot.hpp
#include <iostream>
class Robot{
public: void Speak(){std::cout << "Hello\n";}
}
main.cpp
#include <iostream>
#include "Robot.hpp"
void RobotSpeak(Robot& robot);
void RobotSpeak2(Robot*& robot);
void RobotSpeak3(Robot** robot);
void RobotSpeak4(Robot* robot);
int main(){ return 0; }
When and how would you use RobotSpeak(Robot&) on a object created on the free store and when would you use the others.
Many Thanks in Advance.
Tom
modified on Saturday, May 8, 2010 9:55 AM
|
|
|
|
|
Soo….something like:
Robot* myRobot = new Robot;
RobotSpeak(*myRobot); ?
Oh, and BTW - the calling syntax for RobotSpeak3 would be (*robot)->Speak()
The only parameter passing mechanisms I'd consider using would be those used in RobotSpeak and RobotSpeak4…although I would tend to use a const reference and declare Speak as const if it doesn't modify Robot:
Robot.hpp
#include <iostream>
class Robot{
public: void Speak() const {std::cout << "Hello\n";}
};
main.cpp
void RobotSpeak(Robot const & robot)
{
robot.Speak();
}
int main()
{
Robot* myRobot = new Robot;
RobotSpeak(*myRobot);
return 0;
}
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Thanks for replying .
Whats the difference between passing a object
by derefencing a pointed object and using
a using a Reference To Pointer, and a Pointer Argument,
like RobotSpeak(Robot const & robot) and RobotSpeak(Robot const *& robot ) and also RobotSpeak(Robot const ** robot) .
Tom
|
|
|
|
|
The only time I would use a reference to a pointer or a pointer to a pointer would be so I could modify the passed in pointer. And then, you need to be sure that you don't leak any memory.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
If you refer to the object by reference, it cannot by deleted, which is a good thing.
Where as if you did such as RobotSpeak(const Robot*& const robot) . You could delete the object in the procedure, and if the calling program tried to do any thing to object, it would fail and leak memory or worse.
Thanks Again
Tom
|
|
|
|
|
Tom Moore wrote: Where as if you did such as RobotSpeak(const Robot*& const robot). You could delete the object in the procedure, and if the calling program tried to do any thing to object, it would fail and leak memory or worse.
That's a very dangerous thing to do, and certainly not advisable in any API design. While you can create any level of parameter referencing you want (pointer to pointer to pointer to ...) you really have to consider why you would want to do such a thing, and what side effects you might be leaving yourself open to if you do.
Even if you explicitly state things like this when describing your API, users will always do incorrect things with it. Believe me, I've written what I thought were bomb-proof systems, only to find they weren't
Days spent at sea are not deducted from one's alloted span - Phoenician proverb
|
|
|
|
|
Thanks, I'll be aware of that in the future.
'Bomb-proof', reminds me of the old Atari ST,
whenever that crashed for whatever reason, it
would print cherry bombs on the screen, we calling
bombing out. That was early to mid 90's.
Thanks Again.
Tom
|
|
|
|
|
Not with that signature - you've got a const pointer to a const object - can't call delete on that without casting the pointer...
But even with a reference, you can delete it, like in this (evil, evil) code:
void RobotSpeak(const Robot& robot)
{
Robot* pRobot = const_cast<Robot*>(&robot);
delete pRobot;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Thanks, didn't realize that could be done.
|
|
|
|
|
I would use
void RobotSpeak( const Robot & robot);
with
class Robot
{
public:
void Speak() const
{
std::cout << "Hello\n";
}
};
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 really don't see the point in the standalone RobotSpeak function set. If you have an instance of Robot, say robot, why not just do:
robot.Speak();
And if you have different types of robots saying different things, make Speak virtual and operate through base classes.
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|