|
You mean You want just a class which supports two interfaces rite?
Loka Samastha Sukhino Bhavanthu..!!!
( May all beings be happy and free )
|
|
|
|
|
Yes..I want my component should be support two interfaces, can I do with wizard..in ATL..
Thanks,
Siva
|
|
|
|
|
Hi Siva,
To do that, you can add a class like what you normally do. Thereafter is the tricky part, to remove the class and leave the interface around.
To do that, in the idl file remove the code below for your second class.
[
uuid(8D1E05B3-F610-4450-984E-4DCC4D2442E5),
helpstring("SubClass1 Class")
]
coclass SubClass1
{
[default] interface ISubClass1;
};
In your second class's header file, remove the 2 lines below. The second line will remove unnecessary register entry.
public CComCoClass<csubclass1, &clsid_subclass1="">,
DECLARE_REGISTRY_RESOURCEID(IDR_SUBCLASS1)
In the main cpp file, remove this line
OBJECT_ENTRY(CLSID_SubClass1, CSubClass1)
If I do not remember wrongly that will be it, 2 interface in one COM object. I had done this in one of my DLL and it works.
But if I do not remember wrongly again, you will not be able to see your second interface in VB or .Net whichever the client u are using. What I did, I had to pass the interface out.
Hence I will see the interface like this in VB.
dim a as FirstClass
a.SecondClass.method()
Hope I got your question right as I had also spend a lot of time on something like that.
|
|
|
|
|
Hello all:
I create a com object like follows:
IATLDiceHelpPtr pATLDiceHelp;
HRESULT hr = pATLDiceHelp.CreateInstance(__uuidof(IATLDiceHelp));
if(pATLDiceHelp)
{
pATLDiceHelp->MsgBox(); // here can not execute
pATLDiceHelp->Release();
}
when executethis code,the variable hr is -2147221164;
can everyone tell me why it is failure? and how to fixed it?Thanks a lot!
more information:
interface definition:
[
object,
uuid(C4892EC8-E170-426C-AB99-7E3B403B0324),
dual,
helpstring("IATLDiceHelp Interface"),
pointer_default(unique)
]
interface IATLDiceHelp : IDispatch
{
[id(1), helpstring("method MessageBox")] HRESULT MsgBox();
};
|
|
|
|
|
From "winerror.h":
#define REGDB_E_CLASSNOTREG _HRESULT_TYPEDEF_(0x80040154L)
Note that -2147221164 is 0x80040154 in hex; always quote HRESULTS in hex, not decimal.
REGDB_E_CLASSNOTREG means that the class you tried create an instance of is not registered.
Steve
|
|
|
|
|
For Creation of the COM object try the following code
::CoInitialize(NULL);
IToolBar *pTest;
HRESULT hr=::CoCreateInstance(CLSID_Test,NULL,CLSCTX_INPROC_SERVER,IID_ITest,(void**)&pTest);
if(FAILED(hr))
return 0;
pTest->MsgBox();
pTest->Release();
pTest=NULL;
::CoUninitialize();
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
WE ARE ATTACTING PIC TO A BLACK BOX TO TAKE CERTAIN READINGS.WE ARE ALREADY UTILYSING OUR PC TO SEND PRIORITY COMDS TO ANOTHER PIC. WE WANT TO ATTATCH A PEN DRIVE ON PICS COM PORT AND STORE READINGS TAKEN FROM BLACK BOX. CAN SOMEONE PL PROVIDE US WITH SUITABLE PROGRAM
SHERGILL
|
|
|
|
|
Never SHOUT in forums. It's considered rude and also hard to read.
Look here[^] for posting guidelines.
Also this forum is about COM, as in Component Object Model, not COMmunications ports.
If you need a terminal program I suggest TeraTerm[^] which usually covers the needs.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Shh!
Aside from being loud, this is confusing; you can't generally plug a pen drive into a com port, it goes into a USB host.
Or did you mean that your PIC is sending data to a PC com port and you want to store that to a file on a pen drive plugged into the PC?
Steve S
Developer for hire
|
|
|
|
|
Steve S wrote: you can't generally plug a pen drive into a com port, it goes into a USB host
Naah, you're assuming a lot here.
I know I used a barcode reader that had the shape of a pen that connected to the serial port about 12 years ago, he might have meant a "pen" like that.
Also the PIC16F877 doesn't have any USB ports, but it is equipped with a UART.
You'll find some more info about the MCU here[^].
This guy is completely off topic for this forum since he apparently misunderstood what COM means, but I suspect he needs some kind of terminal program.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Thanks Roger. As it happens, I have a couple of serial programmers for PIC devices, so the link to microchip was kind of redundant for me.
OTOH, a lot of other people might not have, so you've just educated a few
Most barcode wands from when I was a lad* were serial ones, except for the ones which were keyboard wedges. I don't think this USB malarkey will ever really catch on.
Steve S
Developer for hire
*No, I'm not admitting how many decades ago that is
|
|
|
|
|
Steve S wrote: No, I'm not admitting how many decades ago that is
Time flies, doesn't it?
BTW, sorry for telling you things you already knew. Apparently you're not the only one assuming things here... :->
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
It certainly does; of course, my eldest son is old enough to drink in California, and my daughter is old enough to vote in UK elections, so I shouldn't be surprised by anything any more!
No, it was a reasonable assumption.
I wonder if CP ought to run a poll on "Do you know anything about microcontrollers, and do you own a programming device for any of them?"
I never cease to be amazed by what people (including me, of course) don't know. I am given to understand that there are still people who believe that here in the UK we have a democracy and a free press...
Steve S
Developer for hire
|
|
|
|
|
Steve S wrote: It certainly does; of course, my eldest son is old enough to drink in California, and my daughter is old enough to vote in UK elections
Mmm, I know the feeling.
My step-daughter has recently made her choice for secondary upper school. Phweee!
A small comfort is the fact that she's my step-daughter. But anyway...
Steve S wrote: No, it was a reasonable assumption
Actually I was involved in developing the software for a large system with PIC17C756 MCUs.
That was a real challenge since this MCU only have 902 bytes of RAM and there were approximately 80 of them. Long days and nights.
But it was fun.
Steve S wrote: there are still people who believe that here in the UK we have a democracy and a free press...
Yeah, and here in Sweden we officially have virtually none that are unemployed and the small amount of people that cannot be hidden in the system are decreasing...
All the best
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
hey big guy
i know that pen drive goes into a usb port.ever heard off connectors that can be attatched to pic to to connect a pen drive. if you r still not getting it i will send a snap just to make u wise
|
|
|
|
|
hello friends following code is used to show outlook express send mail dialog box. But i am unable to attach a file.
can someone tell me how to do this?
code::::::::::::::::
_NameSpacePtr pNameSpace;
MAPIFolderPtr pOutbox;
_ItemsPtr pOutboxItems;
_MailItemPtr pNewMail;
CComPtr<attachments> pAtach;
RecipientsPtr pRecipients;
RecipientPtr pRecipient;
HRESULT hr = NULL;
_ApplicationPtr m_pApp("Outlook.Application");
CComPtr <_Inspectors> pInspectors;
m_pApp->get_Inspectors(&pInspectors);
m_pApp->get_Session(&pNameSpace);
pNameSpace->GetDefaultFolder(olFolderInbox,&pOutbox);
pOutbox->get_Items(&pOutboxItems);
VARIANT Type;
m_pApp->CreateItem(olMailItem,(IDispatch**)&pNewMail);
CComPtr <_Inspector> pInspector;
hr = pInspectors->Add(pNewMail, &pInspector);
if(FAILED(hr))
return ;
hr = pInspector->Activate();
if(FAILED(hr))
return ;
hr = pInspector->Display();
if(FAILED(hr))
return ;
|
|
|
|
|
I have imported a .dll like as follow:
#import "E:\AtlOcx\Debug\AtlOcx.dll"
In the CLient Application,I wrote like this
BEGIN_INTERFACE_MAP(CATLDiceObjSink, CCmdTarget)
INTERFACE_PART(CATLDiceObjSink, DIID__IATLDiceObjEvents, Dispatch)
END_INTERFACE_MAP()
But when a compiled the client program,It has a error like as follow:
--------------------Configuration: AtlClientTest - Win32 Debug-----------
Compiling...
ATLDiceObjSink.cpp
D:\me\VC学习\ATL\AtlClientTest\ATLDiceObjSink.cpp(61) : error C2065: 'DIID__IATLDiceObjEvents' : undeclared identifier
Error executing cl.exe.
Creating browse info file...
AtlClientTest.exe - 1 error(s), 0 warning(s)
---------------------------------------------------------------------------
Can someone tell me how to include 'DIID__IATLDiceObjEvents' ?
Thanks in advance.
|
|
|
|
|
I think you could use the named_guids attribute when importing the dll.
#import "E:\AtlOcx\Debug\AtlOcx.dll" named_guids
Also include the file: "E:\AtlOcx\Debug\AtlOcx.tlh" (or whatever that is generated) in your code.
this is this.
|
|
|
|
|
use __uuidof(IATLDiceObjEvents) instead of DIID__IATLDiceObjEvents
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
It's ok now!And I want to konw why it works well using DIID__IATLDiceObjEvents in sometimes,but not in my project.
Thank you very much for help!
|
|
|
|
|
Fine,it works only when we imports the GUIDS from the DLL as Follows
#import "mypath\mydll.dll" named_guids
named_guids attribute
The named_guids attribute tells the compiler to define and initialize GUID variables in old style, of the form LIBID_MyLib, CLSID_MyCoClass, IID_MyInterface, and DIID_MyDispInterface
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
-- modified at 0:06 Thursday 18th May, 2006
|
|
|
|
|
I wnat to know how to register a dll com component in C# using windows APi not a shell command.
Please I need it urgently.
|
|
|
|
|
1. Load the dll with ::LoadLibrary()
2. Get the address of the library's exported function DllRegisterServer with ::GetProcAddress()
3. Call the library's DllRegisterServer()
4. Unload the library with ::FreeLibrary()
Like this, pasted from MSDN:
typedef HRESULT (STDAPICALLTYPE *CTLREGPROC)() ;
HMODULE hModule = ::LoadLibrary(m_strPathName) ;
CTLREGPROC DLLRegisterServer =
(CTLREGPROC)::GetProcAddress(hModule,"DllRegisterServer" ) ;
DLLRegisterServer() ;
::FreeLibrary(hModule) ;
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Thank you for your help.
But please could you give me the C# code becuase I am not good in C++.
|
|
|
|
|
ass3aad wrote: But please could you give me the C# code becuase I am not good in C++.
Sorry, I don't do C#, but you should be able to figure it out. I don't think the two languages should differ that much. The flow is the same as in any language and the API calls made are the same.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|