|
Hello everyone,
In ATL wizard (I am using VS 2008) when add a new ATL object, we can assign 4 names,
1. Short Name (under C++ sub-category);
2. Class Name (under C++ sub-category);
3. CoClass Name (under COM sub-category);
4. Interface Name (under COM sub-category);
My question is how they are binded/related together? My current understanding is (please feel free to correct and add more points),
- From COM client point of view, it only knows 3 and 4 when create the class (it knows nothing about real C++ class name defined in 2), and in the template code generated by ATL, 3 and 4 are binded to 2. Am I correct? But how it is binded?
- What is the usage of 1 (Short Name)?
- I always use C++ and always using class/interface GUID other than names defined in 3 and 4 to create instance and access interface, in what scenarios will names defined in 3 and 4 be used and how they are translated/binded into GUID?
thanks in advance,
George
|
|
|
|
|
i have something like this
BYTE aby1 [3] = { 0x12, 0x13, 0x1F};
BYTE aby2 [3] = { 0x21, 0x23, 0x2F};
BYTE * pby1;
pby1 = (BYTE *) malloc (sizeof (256));
pby1 = aby1;
now at the end of pby1 i want to add the elements of aby2 ?
|
|
|
|
|
By judging from the subject line in your post as well as browsing through some of your previous posts it's clear that you have not grasped the concept of Dynamic_memory_allocation[^].
The code snippet you provided doesn't do what you think it does; e.g. you have an obvious "memory leak" since you allocate memory and then let the pointer point to the buffer on the stack. The size of the memory leak is depending on how many bytes the compiler thinks it would take to store the integer 256 .
I strongly advise you to read this[^]!
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hi i have written the bellow code to search the bluetooth device.
<code>
#include <windows.h>
#include <stdio.h>
#include <bthdef.h>
#include <bthsdpdef.h>
#include <BluetoothAPIs.h>
int main()
{
BLUETOOTH_DEVICE_SEARCH_PARAMS BluetoothSearchParams;
BLUETOOTH_DEVICE_INFO BluetoothDeviceInfo;
HBLUETOOTH_DEVICE_FIND hBluetoothDevice;
ZeroMemory(&BluetoothSearchParams, sizeof(BluetoothSearchParams));
ZeroMemory(&BluetoothDeviceInfo, sizeof(BluetoothDeviceInfo));
BluetoothSearchParams.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
BluetoothSearchParams.fReturnAuthenticated= true;
BluetoothSearchParams.fReturnRemembered = true;
BluetoothSearchParams.fReturnUnknown = true;
BluetoothSearchParams.fReturnConnected = true;
BluetoothSearchParams.fIssueInquiry = true;
BluetoothSearchParams.cTimeoutMultiplier = 15;
BluetoothSearchParams.hRadio = NULL;
BluetoothDeviceInfo.dwSize = sizeof(BluetoothDeviceInfo);
hBluetoothDevice = BluetoothFindFirstDevice(&BluetoothSearchParams,
&BluetoothDeviceInfo);
if (hBluetoothDevice != NULL)
{
while (true)
{
wprintf(L"Found a Bluetooth device!\n");
if (BluetoothFindNextDevice(hBluetoothDevice,
&BluetoothDeviceInfo) == false)
{
break;
}
}
}
else
{
wprintf(L"Unable to find a Bluetooth device.\n");
}
return 0;
}
</code>
i have created new win32console project and written the above file i have sdk installed but while compiling it shows that files like bthdef.h & BluetoothAPIs.h & bthsdpdef.h not found....
how to set the project properties so that i can link the files form my sdk folder...
|
|
|
|
|
Did you specify the name of the library in linker settings?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes i have set the additional libraries to my sdk path but even then it is same.
|
|
|
|
|
It's not a linker problem. The compiler is complaining about not finding .h files
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
manju23reddy wrote: how to set the project properties so that i can link the files form my sdk folder...
What version of VS are you using? With VS2005, click Options from the Tools menu. Open Projects and Solutions, and select VC++ Directories.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Suppose I declare a static variable in a dll, and simultaneously launch two applications which use the same dll. Now if I change the value of that static variable from one application, will the other application will be affected by this?
Specifically, will Singletons will behave properly if I declare them in a dll?
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
The NULL Developer wrote: Now if I change the value of that static variable from one application, will the other application will be affected by this?
No, because when a DLL is loaded by a process, it is loaded into the address space of the calling process, creating a copy of the module, which means the data in the DLL used by one process will be separated from the data in the DLL used by the other process.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Thanks Perspx, exactly what I had expected.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
Be carefull with doing that. I remember a problem I had some years ago which consisted also of a singleton in a dll (using static variable). This didn't work because the dll (from which the singleton was coming) had a different instance of the static variable than the exe. Which means that if you have to use the singleton in the exe and in the dll, you will end-up with two copies of the singleton.
|
|
|
|
|
Hi Cedric, can you explain a little bit more about the problem, what was the cause, and how it was resolved? I am sure it will help me to keep your caution in mind while designing in future.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
After searching for a while, I found back a question I asked on codeguru: see here[^]. I didn't go into too much details though.
|
|
|
|
|
Hi!
My project is compiling fine. But it shows linker errrors.
testAI.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: float __thiscall osgGA::GUIEventAdapter::getYmax(void)const " (__imp_?getYmax@GUIEventAdapter@osgGA@@QBEMXZ)
testAI.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: float __thiscall osgGA::GUIEventAdapter::getYmin(void)const " (__imp_?getYmin@GUIEventAdapter@osgGA@@QBEMXZ)
D:\GUI04072008\Release\GUI.exe : fatal error LNK1120: 2 unresolved externals
I've included all the libraries. What to do?
|
|
|
|
|
did u make an entry in the .def file of the dll?
|
|
|
|
|
I don't know about def file. Where it is located?
|
|
|
|
|
looks like u r using n dll right?
then in the solution explorer u will find n .def file in the source files section.
open it and make an entry of ur function name which u want to export.
|
|
|
|
|
if it still doesnt work then try putting the foll:
?getYmax@GUIEventAdapter@osgGA@@QBEMXZ
(which i took from ur post itself)
Prasann
enjoy
|
|
|
|
|
There's no .def file in my solution. Only source and header files are there.
|
|
|
|
|
Are you sure you link with the lib file that is provided with the dll ?
|
|
|
|
|
|
Are you sure your class is exported in the dll ? Can you post the code of the header file for this class ?
Did you also provide a body for those functions ?
|
|
|
|
|
Here it is:
#ifndef DELTA_TestAI
#define DELTA_TestAI
#include <string>
#include <dtCore/refptr.h>
#include <dtABC/application.h>
#include <dtCore/camera.h>
#include "aicharacter.h"
#include <dtCore/collisionmotionmodel.h>
#include <osg/Matrix>
namespace dtCore
{
class Object;
class Transform;
class CollisionMotionModel;
}
namespace dtChar
{
class Character;
}
namespace dtDAL
{
class Project;
}
using namespace dtCore;
using namespace dtChar;
using namespace dtDAL;
class TestAI : public dtABC::Application
{
public:
TestAI(const std::string& mapName = "vismap6", const std::string& configFilename = "config.xml");
protected:
~TestAI();
public:
virtual void Config();
virtual bool KeyPressed(const dtCore::Keyboard* keyboard, int key);
virtual void PreFrame( const double deltaFrameTime );
private:
void LoadDemoMap(const std::string& pStr);
float mSpeed;
bool mDrawNavMesh;
bool char7start;
unsigned int pWaypointNum[7];
unsigned pAISpeed[7];
unsigned pStopWaypoint[7];
std::string mMapFilename;
dtCore::RefPtr<dtCore::Camera> mOverheadCamera;
dtCore::RefPtr<dtAI::AICharacter> mCharacter1;
dtCore::RefPtr<dtAI::AICharacter> mCharacter2;
dtCore::RefPtr<dtAI::AICharacter> mCharacter3;
dtCore::RefPtr<dtAI::AICharacter> mCharacter4;
dtCore::RefPtr<dtAI::AICharacter> mCharacter5;
dtCore::RefPtr<dtAI::AICharacter> mCharacter6;
dtCore::RefPtr<dtAI::AICharacter> mCharacter7;
dtCore::RefPtr<dtCore::Object> m_Obj;
osg::Matrix mCameraOffset;
dtCore::RefPtr<CollisionMotionModel> mMotionModels;
protected:
osg::ref_ptr<osg::Node> _node;
float _velocity;
osg::Vec3 _eye;
osg::Quat _rotation;
osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t1;
osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t0;
float _distance;
void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
void flushMouseEventStack();
};
#endif // DELTA_TestAI
Yes. I defined all the declared functions.
|
|
|
|
|
No, I was talking about the osgGA::GUIEventAdapter class, the one from the dll. Did you write this dll ? If not, from where is it coming from ?
|
|
|
|