|
Thanks Rajkumar,
Cool and wonderful sample!
But I am confused about one line of your code, this line,
auto_ptr<data> pi(produce());
</data>
My question is, auto_ptr should be used with object allocated on heap (can not be on stack), right? So, the function produce returns an object on heap?
regards,
George
|
|
|
|
|
George_George wrote: So, the function produce returns an object on heap?
yes, offcourse
data *Produce(); lets say.
data *Produce()
{
data * pData = new data();
.... fill the pData
return pData;
}
|
|
|
|
|
Thanks Rajkumar,
Your clarification is clear. My question is answered.
regards,
George
|
|
|
|
|
As a side note, you are aware of the pitfalls of std::auto_ptr regarding to ownership, and of the replacements offered by e.g. boost.org ?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks jhwurmbach,
1. It is appreciated if you could let me know what pitfalls do you mean?
2. What replacement do you mean? share_ptr?
regards,
George
|
|
|
|
|
Friends,
In my appln i am using an exported member(static memebr of a clasas) from a dll.
But i am getting a link error on that static member valrible.
In my Dll Project i have set the __EXPORT defenition in the project settings
Im my application i have given lib name in the project settings.
Does any one have any idea. why this happends...?
The dll implemenntation is as follows;
//MyClass.h
#ifdef __EXPORT
#define EXPORT _declspec(dllexport)
#else
#define EXPORT _declspec(dllimport)
#endif
class EXPORT CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.h.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
Does any one have any idea why this happend?????
|
|
|
|
|
Friends,
In my appln i am using an exported member(static memebr of a clasas) from a dll.
But i am getting a link error on that static member valrible.
In my Dll Project i have set the __EXPORT defenition in the project settings
Im my application i have given lib name in the project settings.
Does any one have any idea. why this happends...?
The class implemenntation is as follows;
//MyClass.h
#ifdef __EXPORT
#define EXPORT _declspec(dllexport)
#else
#define EXPORT _declspec(dllimport)
#endif
class EXPORT CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.h.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
Does any one have any idea why this happend?????
|
|
|
|
|
Can you cut and paste the error here please?
Just a stab in the dark, but have you tried:
int EXPORT CMyClass::nValue = 0;
?
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
This is the error message
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
|
|
|
|
|
I already showed you a working sample and suggested the proper settings for your application, please review the latters.
BTW Can you see the DLL exported int with Dependency Walker?
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
|
|
|
|
|
Hi,
I think u are speaking abt another thread that i launched day before yesterday.
Unfortunately that thread lost, i do not how that happend.
So i could not see your reply.
Expeting more help on this topic
Thanks
Prasanth
|
|
|
|
|
Prasanth M V wrote: Unfortunately that thread lost, i do not how that happend.
The Lost Thread ^
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have gone though ur help.It seems that we are in the same path.
But there is still error.
Is there anything related with machine configuration?\
I am Win XP Sp2
Or any other library dependency?
Thanks
Prasanth M V
|
|
|
|
|
The following is a working sample:
DLL header
#ifdef CPPDLL_EXPORTS
#define CPPDLL_API __declspec(dllexport)
#else
#define CPPDLL_API __declspec(dllimport)
#endif
class CPPDLL_API CCppDll {
public:
CCppDll(void);
~CCppDll(void);
static int nValue;
};
DLL source
CCppDll::CCppDll()
{
return;
}
CCppDll::~CCppDll()
{
return;
}
int CCppDll::nValue = 0;
Application source
#include "stdafx.h"
#include "..\\..\\CppDLL\\CppDLL\CppDLL.h"
int _tmain(int argc, _TCHAR* argv[])
{
CCppDll::nValue =5;
}
It works fine on my system (VS 2005, Win XP).
Have you checked again your client project settings? What about the little test with Dependency Walker?
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
|
|
|
|
|
Hi ,
I have just gone through your Dll implementation code.
I think we both moving with same implementation.
But still there is error in my PC.
My Build environment details is as follows:
OS – Win XP SP2
IDE – Microsoft Visual 6.0(c++)
I tested the same implementation in another PC which has the same configuration, but the same error.
Thanks
Prasanth M V
|
|
|
|
|
this can occur if u donot define the nValue in ur DLL, but ur code shows u defined the variable,
I see two possibility,
1) u may be linking to wrong export library, that can happen if u r moving projects, but given fixed path.
2) ur error message shows it is not dllimport, it is normal class declaration,
if dllimport then following can be the error message
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static int CMyClass::nValue" (__imp_?nValue@CMyClass@@2HA)
not this
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
this can happen if ur using different header file, other than that used in DLL project which doesnot have the dllimport keyword
modified on Tuesday, February 19, 2008 7:23 AM
|
|
|
|
|
Hi.
I have 2 web cameras connected to my PC.
capGetDriverDescription retreives:
Microsoft WDM Image Capture (Win32)
The capDlgVideoDisplay macro displays a dialog box in which I can choose between 2 web cameras.
How to switch between web cameras from my code (not using capDlgVideoDisplay macro)?
Or how to enumerate capturing devices and then select one?
Thank you in advance!
TomazZ
|
|
|
|
|
You can't with VFW.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want to save a bitmap image in Visual C++ 2003.I use the save method of the bitmap class of Gdiplus this way:
Gdiplus :: bitmap mybitmap;
mybitmap.save (L"C:\myFolder\",&bmpClsid);
But I get a win32Error.
Thanks in advance.
|
|
|
|
|
Did you try with CImage class? it has save method.
|
|
|
|
|
I want to use GDIPlus:: Image.
|
|
|
|
|
MozhdehQeraati wrote: mybitmap.save (L"C:\myFolder\",&bmpClsid);
file path error?
something like L"C:\\myFolder\\image1.bmp"
|
|
|
|
|
i Test with this format but get win32error.
|
|
|
|
|
Hi,
Did u start the GDI + engine?
ULONG_PTR m_gdiplusToken;
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
Bitmap *pBitmap = Bitmap::FromFile(/*File name*/);
CLSID Clsid = {0};
GetEncoderClsid(L"image/bmp", &Clsid))
CString strFilePath = "C://1.bmp";
pBitmap->Save(strFilePath.AllocSysString(),&Clsid);
GdiplusShutdown(m_gdiplusToken);
Prasanth M V
Software Engineer.
|
|
|
|
|
I would like to know the value of win32 error.
|
|
|
|