|
I ve downloaded a Flash Com Objects from http://bukoo.sourceforge.net. I ve registered the dll. Then i imported the dll in VC. Please anyone explain how to use the COM object.
ThankYou
|
|
|
|
|
You will either need a header file that indicates the interfaces for the object, or the DLL needs to contain a typelibrary. If the DLL contains a type library you can use the #import command at the top of your file to automatically extract the data and create a header file for you. Look up the #import command in MSDN.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I ve downloaded a Flash Com Objects from http://bukoo.sourceforge.net. I ve registered the dll. Then i imported the dll in VC. Please anyone explain how to use the COM object.
ThankYou
|
|
|
|
|
Anonymous wrote: I ve downloaded a Flash Com Objects from http://bukoo.sourceforge.net. I ve registered the dll. Then i imported the dll in VC. Please anyone explain how to use the COM object.
I think you have to look for some beginner books
"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
|
|
|
|
|
Dear all:
I generated a test certificate by the following command :
makecert -sk test1 -r -ss test.
I want to generate a real certificate,could you give me some advice.
thanks a lot.
liuage
|
|
|
|
|
I wrote a method in COM, has two parameters, BSTR bstrUserID and BSTR bstrUserPwd. I set type in SQL Server as varchar, I used stored procedure to execute a search in database.
Method:
STDMETHODIMP CStudentManager::LogOn(BSTR bstrUserID, BSTR bstrUserPwd)
{
// TODO: Add your implementation code here
BSTR UserID = ::SysAllocString(L"UserID");
BSTR UserPwd = ::SysAllocString(L"Passward");
VARIANT vUser, vPassword;
vUser.vt = VT_BSTR;
vUser.bstrVal = bstrUserID;
vPassword.vt = VT_BSTR;
vPassword.bstrVal = bstrUserPwd;
m_Comm->CommandText = L"LogOn";
HRESULT hr = AppendParameter(UserID, adChar, vUser, adParamInput,20);
if(SUCCEEDED(hr))
hr = AppendParameter(UserPwd, adChar, vPassword, adParamInput,20);
if(SUCCEEDED(hr))
m_Comm->Execute(pvtEmpty1, pvtEmpty2, adCmdText);
if(hr == 0)hr = S_OK;
else hr = E_FAIL;
m_Comm->Parameters->Release();
m_pRs->Close();
::SysFreeString(UserID);
::SysFreeString(UserPwd);
return hr;
}
Stored Procedure:
Create Procedure LogOn
(
@ID,
@Password
)
as
if EXISTS(Select userid from users where userid = @ID and userpwd = @Password
return 0
else
return 1
Go
I used a client function to logon: hr = pManager->LogOn(LogonID, LogonPwd);
I found the function can work, but always return E_FAIL even when database has userid and password.
I thought there is some wrong in define the type, but I can not find it out.
So could anyone tell me when I used BSTR in COM and varchar in SQL SERVER, what should i pay attention to ?
|
|
|
|
|
chq12 wrote:
BSTR UserID = ::SysAllocString(L"UserID");
...
HRESULT hr = AppendParameter(UserID, adChar, vUser, adParamInput,20);
...
Procedure LogOn(@ID,...
Is it the valid relation between "UserID" and "ID"? Is it the same parameter?
With best wishes,
Vita
|
|
|
|
|
Yes, it is. Should these two be same? I mean, if I use UserId in COM as the parameter name, so I should use @UserID in stored procedure. Is it right?
|
|
|
|
|
I think that they must be the same. Try it.
With best wishes,
Vita
|
|
|
|
|
I'll create a IPictureDisp dervied class with a copy constructor, to insert LPPICTUREDISP in an array as follows:
OCArray<picturedisp> m_Pics;
m_Pics.Add(new PICTUREDISP(*pPic));
The point is, that the derived class I has created don't works. Maybe someone can write an example?
thx
Martin
|
|
|
|
|
While you are working with the interfaces, you should not try to copy the content of the interface pointer, i.e. *pPic.
To copy the object, you MUST use the copy of pPic, i.e. IPictureDisp* pPicNew = pPic; pPicNew->Addref(); and pPicNew->Release(); after the stopping of its usage.
You should implement the member OCArray::Add(IPictureDisp* pPic) under above requirements and use m_Pics.Add( pPic );
With best wishes,
Vita
|
|
|
|
|
I've already done, that don't works.
is there another way to do it?
thx
Martin
|
|
|
|
|
And what is wrong? Let us look at your PICTUREDISP constructors/destructor. Also, what is a OCArray class?
With best wishes,
Vita
|
|
|
|
|
The OCArray is a faster CArray class (you can find it on this page).
The variable pPic is a LPPICTUREDISP an is passed by a function called from a VisualBasic application. (It is only a temporary variable).
It should work like that:
1. pPic is passed to the function
2. the function inserts the pPic into the array
3. and calls a function that updates the thumbnail view.
The point is that you can only insert two pic's, if you'll insert a third one the ocx crashes. Furthermore all pictures become the last inserted picture.
The declaration of LPPICTUREDISP is the standard MFC declaration.
The two files of my PICTUREDISP class can you find on:
http://www.martin.krellmann.net/PICTUREDISP.h.txt
http://www.martin.krellmann.net/PICTUREDISP.cpp.txt
|
|
|
|
|
Well. I have a look at your files.
PICTUREDISP(IPictureDisp* lpDisp)
{
if (this != NULL)
this->Release();
if ((lpDisp != NULL) &&
SUCCEEDED(lpDisp->QueryInterface(IID_IPictureDisp, (LPVOID*)this)))
{
ASSERT(this != NULL);
}
}
ULONG STDMETHODCALLTYPE PICTUREDISP::Release()
{
return this->Release();
}
Why have you decide to call the Release() in the constructor? You must get the endless loop, IMHO.
virtual ~PICTUREDISP();
You should not use the virtual destructor. Your vtable will not correspond to the vtable of a class PICTUREDISP during a destructor call (QueryInterface will replace this vtable).
To avoid the AddRef/Release problem you must also realize the operator of copying with your technique.
PICTUREDISP& operator=(const PICTUREDISP& src)
{
...
}
In summary I would like to tell you that your technique is very doubtful and is fraught with mistakes. Though it may have the right on life. Be attentive! And often use Debug Session!
With best wishes,
Vita
|
|
|
|
|
I think that is to difficult for me. Maybe you could modify my source-files an mail them to me: martin2002@web.de.
Is there a better technique to relaize the view. Well pherhaps it is a good way in VB, but maybe not in C++? So you could figure out that I'm quite a good VB programmer, but these MFC/COM/ATL thing are to difficult for me yet. But it is very necessary to realize the thumb view.
Please help me ...
|
|
|
|
|
I wrote an ActiveX. It is included in an HTML page with a codebase information used to install the ActiveX on the user machine.
When the user has an administrator account (WinNT and Win2000) or an account with rights, it works. Else, the ActiveX is not instanciate in the HTML page.
Does anybody know how to force the install of an ActiveX with a standard Windows user account ?
|
|
|
|
|
Hi,
I get a linker error when I try to compile this class that contains a sink object in my ATL COM project.
"error LNK2005: "struct ATL::_ATL_FUNC_INFO OnNewUpdateInfo" (...) already defined in EventClient.obj"
Here is the listing of the Header file that conatians the sink object.
// EventClient.h: interface for the EventClient class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_)
#define AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#import "D:\TreeServer\TreeServer.tlb" no_namespace, named_guids, raw_interfaces_only, raw_native_types
//#include "D:\TreeServer\TreeServer.h"
//#include "D:\TreeServer\TreeServer_i.c"
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
/************************************************************/
// Info for the events handler.
ATL::_ATL_FUNC_INFO OnNewUpdateInfo = {CC_STDCALL, VT_EMPTY, 1, {VT_BSTR}};
class CEventClient
: public IDispEventSimpleImpl<1, CEventClient, &DIID__ITreeUpdateEvents>
{
public:
CEventClient(ITreeUpdate *pITreeUpdate);
virtual ~CEventClient();
// The sink method.
void __stdcall OnNewUpdate(BSTR msg)
{
USES_CONVERSION;
m_bstrInMsg = msg;
SysFreeString(msg);
}
BEGIN_SINK_MAP(CEventClient)
SINK_ENTRY_INFO(1, DIID__ITreeUpdateEvents, 1, OnNewUpdate, &OnNewUpdateInfo)
END_SINK_MAP()
private:
ITreeUpdate *m_pITreeUpdate;
BSTR m_bstrInMsg;
};
#endif // !defined(AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_)
Any help would be great. I've been trying to track down this error for days now. ;(
Thanks in advance.
Ken
|
|
|
|
|
You variable is in the H file, thus being declared twice. Place an extern in the H file and the actual variable in a CPP.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi!
I am a developer and I work with DCOM on Windows98. The question is: is there any problem to use a CComPtr object as a class member?
Thanks.
Gian.
|
|
|
|
|
Nope, not at all. I use it all the time.
The only problem I have ever seen with CComPtr is that it doesn't work in STL collections. But there is a CAdapt class that helps with this problem.
Instead of std::vector <ccomptr <isomething=""> >, you have std::vector <cadapt <ccomptr="" <isomething=""> > >.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi everybody,
I'm a complete COM beginner and I'm wrestling with my first project using MSVC.
Using the ATL wizard I can successfully create a simple DLL (add simple ATL object, AddMethod).
My problem is how can I return a value from my method ? I DO NOT want to pass pointers, which I then manipulate within the method but I want to be able to return the value "directly" (retVal = obj.mymethod()). I'm sure this can be done, but it seems the return type of COM methods is always HRESULT !??
Can I do this using properties (AddProperty) ?
A few lines of example code would be great.
Many thanks,
Axel
|
|
|
|
|
It is completely possible to create a COM interface function that returns the value directly like this:
DWORD GetCount();
However, I would only recommend doing this if you are only writing this object for use in your programs, and you will be using the object as an INPROC_SERVER.
If you want to write COM objects that are truely binary compatible, and can be used by other languages than C++, like VB, then you will need to alway return HRESULT. The reason why is for programs that perfrom network or interprocess communication through COM objects. Whenever you expand the boundaries of your program, there are certain situations that can occur that are out of your control, like the user disconnects their computer from the network. The other libraries that COM depends on will use the HRESULT to indicate this to your program or the program that is using your object.
If you do not use pointers to return values to the user, it becomes more difficult to marshal your data across process boundaries and computers.
Here is a simple prototype for a Get procedure:
HRESULT __stdcall GetCount(DWORD *dwCound);
You want to use the stdcall calling convention for all of your functions in COM, because this is the convention that all programs expect when dealing with a COM interface. _cdecl is the default for VC++.
The bool Essential COM,/i> by Don Box is very insightful for learning COM.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If you want to get a retval from an ATL/COM function, you have to declare the variable that stores the retval as [out, retval] in the ATL Interface.
Example:
interface IExampleClass : IDispatch
{
[id(1), helpstring("Method ExampleFunc")] HRESULT ExampleFunc([in] int nParam1, [in] int nParam2, [out, retval] int* nRet);
}
|
|
|
|
|
Hi
Iwant to develop service in which I need to create a thread.
How can I implement a thread in a service?.I am using ATL com Wizard to create the service.
Thanks
Pathi
|
|
|
|
|