|
I think you cannot compile the XXXX_i.c file.
I am not sure about Managed C++, but in native code, it must not be compiled that way. It can be #include d, or the pre-compiled header for it, turned off.
this is this.
|
|
|
|
|
can spmebody pls advice me how to fire IHTMLSelectElement onchange event in mfc .. i tried IHTMLWindow2 execscript......... but this does not work since the javascript function uses this pointer
|
|
|
|
|
hello,I wrote a property named get_Popvalue(long *nValue),
STDMETHODIMP CATC:get_Popvalue(long *nValue)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = m_dSendBytes;
TRACE1("m_dSendBytes:%d\n",m_dSendBytes);
//m_dSendBytes is not changed here??
return S_OK;
}
and m_dSendBytes is a public variable the defined in the class CATC.
m_dSendBytes will be changed in another function CATC:NotifyData()
void CATC:NotifyData(long nSize)
{
m_dSendBytes += nSize;
//m_dSendBytes can be changed here
}
but m_dSendBytes can not get correctly by com invoked.
Can you tell me why? Thanks
|
|
|
|
|
Can anyone tell me is it possible to make a C# project as a Client to a COM component. If yes, then how to do that. To be precise, I have made a Client in managed C++ which is using a COM component. In managed C++ Client I call CoInitialize(NULL); which works, but I don't think we can write CoInitialize(NULL); in a C# file.
Please Suggest!
|
|
|
|
|
Hello rahultaing,
In your C# project, perform the following :
1. Make a reference to the Type Library File or to the Executable File (DLL or Exe) of your COM component.
1.1 Go to the "References" section of the "Solution Explorer".
1.2 Right click "References" and select "Add Reference".
2. The "Add Reference" dialog box should appear.
2.1 Select the "COM" tab.
2.2 Click on the "Browse..." button.
2.3 A typical file section dialog box should appear.
2.4 Navigate to your component's TLB or DLL or EXE file and select it.
3. An Interop Assembly will be created dynamically for your COM Component.
3.1 The Object Browser of your Visual C# IDE should now contain an entry for your COM component's Interop Assembly. Look out for this.
3.2 The types contained in the Interop Assembly are important for you to use in your source codes. They will usually be scoped by a namespace that has the form "XXXLib".
3.3 Among the types will be a name for your component's class.
3.4 In your C# code, declare this class as per normal using "new".
3.5 Use your class object normally, calling on its properties and methods.
4. What we have just done is something known as COM interop.
4.1 There is no need to call CoInitialize() nor CoUninitialize(). These are called on your behalf by the .NET framework.
4.2 There is also no need to AddRef() or Release() your COM components. The objects are garbaged collected.
Best Regards,
Bio.
|
|
|
|
|
Hi,
Is one of the Windows services in charge of instantiating COM objects, or is it more integrated into the OS than that?
When an out-of-process server is started, does the system start it with a call to CreateProcess?
Thank you,
Rich
|
|
|
|
|
The COM subsystem in the OS is responsible for loading/running COM servers as necessary. The server itself hands out an IClassFactory interface, and that IClassFactory implementation actually creates COM objects.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Can anyone tell me the possible cause of this linker error? I am making a Communicator Component, in the Communicator.h file I write #include "Sockets.h", the Sockets.h file is in the correct folder and contains a class SocketSystem, So now when I declare an object of SocketSystem in my Communicator.h file which is a component that I am trying to make, the above linker error occurs.
Please help!!!
Note: My Sockets.h is a normal C++ header file which contains different Classes and is not included in the project but is present in the same folder.
|
|
|
|
|
Did you make sure to include the necessary .LIB files in your project's "Additional Dependencies" property?
|
|
|
|
|
LNK2001 error means that your code is referencing functions that the linker
cannot find.
You have to tell it where to find those functions.
Most likely, the functions appear in some DLL that is not part of your
program.
What are the names of the functions that it can't find?
Post some of the exact error messages it is giving you.
Rich
|
|
|
|
|
Communicator.obj : error LNK2001: unresolved external symbol "public: __thiscall SocketSystem::SocketSystem(void)" (??0SocketSystem@@QAE@XZ)
Communicator.obj : error LNK2001: unresolved external symbol "public: __thiscall SocketSystem::~SocketSystem(void)" (??1SocketSystem@@QAE@XZ)
Debug\Trial.dll : fatal error LNK1120: 2 unresolved externals
These are the error messages which I get when I declare an object of SocketSystem Class which is present in my "Sockets.h"
|
|
|
|
|
OK, I understand that the SocketSystem class is declared in "Sockets.h", but where is the class defined? Where are the actual functions located?
Do you have the source for the SocketSystem class, or do you only have the compiled version?
|
|
|
|
|
The "Sockets.h" file only contains the declaration of the functions, and the functions are implemented in "Sockets.cpp".
The Sockets.cpp file is also present in the same folder as Sockets.h
|
|
|
|
|
Well, that must be the problem. You just need to add the Sockets.cpp file to your project.
|
|
|
|
|
Let me ask an easier question:
Do you have a file called "Sockets.cpp" ?
If you have a file by that name, add it to your project, then rebuild, and see if it works.
|
|
|
|
|
Is it mandatory to add the files in the project? I mean I have the files in the same project folder but I have not added those files in my project itself. I tried doing that earlier, but it gave me around 17 linker errors on that, so I removed those files from my project.
|
|
|
|
|
The files which contain the actual implementations of the functions must be part of your project, otherwise how else does the compiler generate code for those functions?
If including the Sockets.cpp file caused more linker errors, then that means that there must be OTHER .cpp files that must ALSO be included.
|
|
|
|
|
Yes I knew about it and so I even tried adding all those 4 modules that I used to use in my previous C++ project. Now when I add all those files as well, the compiler again gives me a linker error, I will list those errors in 5 minutes from now. Please see if that makes any sense to you.
|
|
|
|
|
Linking...
Creating library Debug\Trial.lib and object Debug\Trial.exp
Sockets.obj : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function "public: static class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > __cdecl SocketSystem::GetLastMsg(bool)" (?GetLastMsg@SocketSystem@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "public: __thiscall SocketSystem::SocketSystem(void)" (??0SocketSystem@@QAE@XZ)
Sockets.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function "public: __thiscall SocketSystem::~SocketSystem(void)" (??1SocketSystem@@QAE@XZ)
Sockets.obj : error LNK2019: unresolved external symbol __imp__inet_ntoa@4 referenced in function "public: static class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > __cdecl SocketSystem::getIP(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (?getIP@SocketSystem@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function "public: static class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > __cdecl SocketSystem::getIP(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (?getIP@SocketSystem@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function "public: static class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > __cdecl SocketSystem::getIP(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (?getIP@SocketSystem@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
Sockets.obj : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function "public: __thiscall Socket::~Socket(void)" (??1Socket@@QAE@XZ)
Sockets.obj : error LNK2019: unresolved external symbol __imp__shutdown@8 referenced in function "public: __thiscall Socket::~Socket(void)" (??1Socket@@QAE@XZ)
Sockets.obj : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "public: bool __thiscall Socket::connect(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >,int)" (?connect@Socket@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "public: bool __thiscall Socket::connect(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >,int)" (?connect@Socket@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__send@16 referenced in function "public: void __thiscall Socket::send(char const *,unsigned int)" (?send@Socket@@QAEXPBDI@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "public: void __thiscall Socket::recv(char *,unsigned int)" (?recv@Socket@@QAEXPADI@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function "public: __thiscall SocketListener::SocketListener(int)" (??0SocketListener@@QAE@H@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function "public: __thiscall SocketListener::SocketListener(int)" (??0SocketListener@@QAE@H@Z)
Sockets.obj : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function "public: class Socket __thiscall SocketListener::waitForConnect(void)" (?waitForConnect@SocketListener@@QAE?AVSocket@@XZ)
Debug\Trial.dll : fatal error LNK1120: 16 unresolved externals
Build log was saved at "file://c:\Documents and Settings\ashu\Desktop\Trial\Trial\Debug\BuildLog.htm"
Trial - 17 error(s), 0 warning(s)
List of 17 linker errors that are generated when I include all the files that I use.
|
|
|
|
|
OK now we are getting somewhere.
You must include the Ws2_32.lib file in your project's "Additional Dependencies" property.
Do you know how to set that property?
Those functions in the error messages are located in the ws2_32.dll file.
|
|
|
|
|
How do we use boolean variables in COM?
|
|
|
|
|
Hello rahultaing,
There are actually 3 different boolean types defined in IDL :
1. The boolean type (8 bits) which is equivalent to a "char" typein C++.
2. The VARIANT_BOOL (16-bits) which is equivalent to a "short" type in C++.
3. The BOOL type (32-bits) which is equivalent to a "long" type in C++.
For inter-operability with other COM development languages like VB, always use VARIANT_BOOL.
Best Regards,
Bio.
-- modified at 3:38 Sunday 9th April, 2006
|
|
|
|
|
How do we write Constructors & Destructors in COM, Is it possible? If it is not possible then how and where should I perform the initialization task?
|
|
|
|
|
Hello rahultaing,
COM does not provide any specifications for constructors and destructors. To perform initialization for COM objects written in ATL, use the FinalConstruct() (for initialization) and FinalRelease() (for uninitialization) methods.
Best Regards,
Bio.
|
|
|
|
|
Hello,
How to freeze panes in Excel Spreadsheet?
Thanks.
|
|
|
|