|
chaoticSilence wrote: I'm trying to return other numbers like S_FALSE or another postive numbers like 2 or 3. I'm getting a zero value from the visual basic application.
I am Lil Confused! i want to how are you checking return value in Visual Basic Component! could you show me both Visual C++ function and Visual Basic Application code snippet!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Alok, Sorry for the confusion, I haven't really developed in ATL before. I used Visual C++ 6 to create my ATL DLL. This is basically wrapper around some of my code so I can access it from a Visual Basic code
Here is snippet one of my interface implementation
STDMETHODIMP CTagger::Read(int startAddr, int numOfBytes, BSTR* data)
{
// I do my work
CString tempData;
if( m_ioRdr.Read(startAddr,numOfBytes, tempData) < 0)
{
//I clean up my code here
// not shown here
return FAIL; // FAIL is -1
}
*data = tempData.AllocSysString();
return S_OK;
}
Here is a snippet of VB
Dim myTag As Object
Set myTag = CreateObject("CIMTagger.Tagger")
Dim rtnCode as Integer
Dim rtnData as String
rtnCode = myTag.Read(0,8,rtnData)
if rtnCode < 0
' I display the error code and exit
End IF
The issue is I keep getting 0 for my rtnCode in Visual Basic even when there is an error. So I wasn't sure how to check rtnCode in the vb app. I was just thinking about making my interface signature the following
Read(int startAddr, int numOfBytes, BSTR* data, int* rtnCode)
I appreciate any feedback.
|
|
|
|
|
chaoticSilence wrote: STDMETHODIMP CTagger::Read(int startAddr, int numOfBytes, BSTR* data)
actaully if you want to return some value from the atl function, then your method defination in the idl file should be like this
Read([in]int startAddr,[in]int numOfBytes,[out]BSTR* data,[out,<code>retval</code>]int nRet)
this will be correct way of returing error code from the ATL DLL
........
[ot] I am on leave from tommorow for next 7-9 days... if still some problem persist or you can't able to understand above,then you have to wait till feb for further reply!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
-- modified at 1:23 Sunday 26th February, 2006
|
|
|
|
|
Hi Alok,
i got struck with your 20th step. i guess.
when i compile i get a error message
D:\VC++\SimpleAtlCom\SimpleObj.cpp(61) : error C2039: 'Fire_TotalMarks' : is not a member of 'CSimpleObj'
d:\vc++\simpleatlcom\simpleobj.h(11) : see declaration of 'CSimpleObj'
Generating Code...
Error executing cl.exe.
SimpleAtlCom.dll - 1 error(s), 0 warning(s)
so i placed the code
void Fire_TotalMarks(long TotalMarks);
in CProxy_ISimpleObjEvents class header file.
i got the following message..
Linking...
Creating library Debug/SimpleAtlCom.lib and object Debug/SimpleAtlCom.exp
SimpleObj.obj : error LNK2001: unresolved external symbol "public: void __thiscall CSimpleObj::Fire_TotalMarks(long)" (?Fire_TotalMarks@CSimpleObj@@QAEXJ@Z)
Debug/SimpleAtlCom.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
SimpleAtlCom.dll - 2 error(s), 0 warning(s)
then i place the code
void Fire_TotalMarks(long TotalMarks);
in SimpleObj class header file.
i got the following message
Linking...
Creating library Debug/SimpleAtlCom.lib and object Debug/SimpleAtlCom.exp
SimpleObj.obj : error LNK2001: unresolved external symbol "public: void __thiscall CSimpleObj::Fire_TotalMarks(long)" (?Fire_TotalMarks@CSimpleObj@@QAEXJ@Z)
Debug/SimpleAtlCom.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
SimpleAtlCom.dll - 2 error(s), 0 warning(s)
can you tell me what is the problem...
-- modified at 1:41 Friday 30th December, 2005
|
|
|
|
|
Sorry man. It's working....
|
|
|
|
|
senproin wrote: Sorry man. It's working....
noprobs, you are always welcome
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
But as you guide says, step 20, it shuldn´t create automatically the function "VOID Fire_TotalMarks(SHORT TotalMarks)..." ?
Why, in my case, it was not created.
Coping the function from your project does the work.
So for making from scratch something is missing.
I am very interested on this.
Your article is very good.
Congratulations
Miguel
|
|
|
|
|
Hello,
I was trying to implement this code in my system. But i am not able to do it. Might be silly mistakes but cant figure it out.Plewase help. I am a newbie to this field
THis is the error i am getting..
Compiling...
SimpleAtlCom.cpp
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : error C2065: 'IID__ISimpleObjEvents' : undeclared identifier
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : error C2440: 'static_cast' : cannot convert from 'class CSimpleObj *' to 'class ATL::_ICPLocator *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : fatal error C1903: unable to recover from previous error(s); stopping compilation
SimpleObj.cpp
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : error C2065: 'IID__ISimpleObjEvents' : undeclared identifier
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : error C2440: 'static_cast' : cannot convert from 'class CSimpleObj *' to 'class ATL::_ICPLocator *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Error executing cl.exe.
SimpleAtlCom.dll - 6 error(s), 0 warning(s)
Dileep
|
|
|
|
|
Dileep_kerala wrote: E:\VC Study Examples\COM_ATL\SimpleAtlCom\SimpleObj.h(34) : error C2065: 'IID__ISimpleObjEvents' : undeclared identifier
I believe you have tried above article by your own .. thats nice.. any Way just convert 'IID__ISimpleObjEvents' to 'DIID__ISimpleObjEvents' in Class Header File.
Dileep_kerala wrote: Might be silly mistakes but cant figure it out.
Hai.. No Probs Buddy...
you are always welcome
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thank you very much for this article! You have no idea how much it helped me out.
Anyway, I ran into this problem too. Why didnt visual studio put in the correct name? And where is the definition for "DIID__ISimpleObjEvents"
thanks again
DrDataRulz.net
|
|
|
|
|
rebuild it dude..
"If it were machines, the pair_programming seem to work, but for humans it is pair_crackdown that seems to work! " - Nisamudheen
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Guys,
Could you please give me some idea on how to add an ATL control in the Visual C++ 2005 (final)? It seems that there is no "insert" menu and ATL Object Wizard in this new version visual c++. Thanks a lot!
Andrew
|
|
|
|
|
andrew95 wrote: It seems that there is no "insert" menu and ATL Object Wizard in this new version visual c++.
I still have to see/explorer the VS2005 IDE.. i havn't got the CD yet...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi Alok,
Thanks for your prompt reply. You may download it from the Microsoft website. Good luck!
Andrew
|
|
|
|
|
andrew95 wrote: You may download it from the Microsoft website. Good luck!
I awaiting same from my MSDN subscription!.. Downloading VS2005 from MS Site going to take weeks for me here in my city!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
In Solution Explorer, right click SimpleAtlCom project node->Add->Class and select ATL Simple Object under ATL.
Hope that helps.
|
|
|
|
|
Right you say!
"If it were machines, the pair_programming seem to work, but for humans it is pair_crackdown that seems to work! " - Nisamudheen
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello,
Very good article. I want to use namespace in this com dll. How i have to do? I need to use this dll in a C# project, and i think it's better to work with namespace. Can i use namespace in c++ project or in vb project?
Thanks,
Mihai
|
|
|
|
|
MihaiChioariu wrote:
Can i use namespace in c++ project or in vb project?
I am Afraid, I Doesn't understand your problem, AFAIK The COM DLL itself create namespace to work with.!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
yes, shure i want to use namespace in Com DLL (i don't know how?), and used them in c++ and vb project (how?). using... i can't see any namespace only the dll name with using.
Thanks,
Mihai
|
|
|
|
|
MihaiChioariu wrote:
want to use namespace in Com DLL (i don't know how?), and used them in c++ and vb project (how?). using... i can't see any namespace only the dll name with using.
Yeap, The Compiler generate the namespace based on the dll name
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello Alok,
Great article, Alok. Deserves a 5 for simplicity and a well thought-out pace of explanation.
How about a Part Two for this excellent primer ? Suggestions :
1. Demonstrate defining a generic set of interfaces via a "pure interface" ATL project, the purpose of which is to centrally maintain the definition of interfaces, structs, enums, etc which are used throughout a development team.
2. Demonstrate importing this IDL into the IDLs of implementation projects. Demonstrate the process of such implementations. This way, newbies can see that there can be multiple implementations of a generic set of interfaces.
3. Demonstrate how a client application can dynamically choose and use one or more actual implementation(s) of interfaces.
Just a few suggestions. Once again, a great article, Alok. Thanks.
Best Regards,
Bio.
|
|
|
|
|
Lim Bio Liong wrote:
Great article, Alok. Deserves a 5 for simplicity and a well thought-out pace of explanation.
Thanks Mr. Liong, It's great pleasure to hear above from you and sorry for replying late.
Lim Bio Liong wrote:
. Demonstrate defining a generic set of interfaces via a "pure interface" ATL project, the purpose of which is to centrally maintain the definition of interfaces, structs, enums, etc which are used throughout a development team.
2. Demonstrate importing this IDL into the IDLs of implementation projects. Demonstrate the process of such implementations. This way, newbies can see that there can be multiple implementations of a generic set of interfaces.
3. Demonstrate how a client application can dynamically choose and use one or more actual implementation(s) of interfaces.
Frankly Speaking Sir, I too struggling with these concepts, Could you please provide me any link in
support of this. Thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello Alok,
>> ... sorry for replying late
No problem, Alok.
>> Frankly Speaking Sir, I too struggling with these concepts, Could you please provide me any link in support of this. Thanks.
That's your good old humble nature as usual, Alok
I'll follow up with more messages expounding some of the techniques mentioned.
Best Regards,
Bio.
|
|
|
|
|
Lim Bio Liong wrote:
I'll follow up with more messages expounding some of the techniques mentioned.
Thanks, I will Wait for that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|