|
Hi again
I move #include <afxwin.h>
in file StdAfx.h
but now I get linking error
link: executing 'C:\PROGRA~1\MICROS~4\VC98\Bin\link.exe'
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in RecToR.obj
nafxcw.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in RecToR.obj; second definition ignored
Creating library ReleaseMinDependency/RecToR.lib and object ReleaseMinDependency/RecToR.exp
ReleaseMinDependency/RecToR.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
How can I solve that?
Tomaz Rotovnik
|
|
|
|
|
I think I found the problem.
I write down steps for those who will have the same problem
1. Because dll which I build is Extension DLL I shouldn't have definition _USRDLL in preprocessor definitions
2. I include CEdit, CString classes which need afxwin.h header
so I put #include <afxwin.h> as first include statement in StdAfx.h header file before all other #include statements. (solved C1189 error)
3. I think CDialog class is MFC so I also set option:
Use MFC in a Shared Dll
Tomaz Rotovnik
|
|
|
|
|
Hi, I am having an issue trying to post data using the serverxmlhttp interface. Here is a brief overview:
I am collecting data and automatically sending this data back to central repository. Currently, ftp and smtp protocols perform as expected. HTTP is another story. I have a microsoft service running that kicks of the 'transmitter' when there is enough data to send. That service is running with an administrator account (not THE administrator, but a created user with administrative privaledges.) Anyway, when this service kicks off and creates the COM component that actually does the transmissions, my http transmission portion returns a "Access denied" error. If I run the COM component from an executable, however, the transmission succeeds.
I thought that this was an inheritable rights type problem dealing with the service, however, I have redesigned the system and am now having a server component create and launch the COM transmitter. I still am having the same issue.
Any help would be greatly appreciated. Thanks
|
|
|
|
|
:(Well, sorry to disturb for what surely is an easy thing, but...
Which function must i call if the COM library i want to use defines an interface but no class ?
IID_TheClass is defined, but there is no
CLSID_TheClass, that any tutorial/example/help file i read is using ?
I just can't call CoCreateInstance(Ex)...
Note: i'm trying to use within C++ the Microsoft Euro Converter, that is
----------------------------------------
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: MSOEURO.DLL
[
uuid(76F6F3F5-9937-11D2-93BB-00105A994D2C),
version(1.0),
helpstring("Microsoft Office Euro Converter Object Library")
]
library MsoEuro
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface Converter;
[
odl,
uuid(76F6F3F4-9937-11D2-93BB-00105A994D2C),
dual,
oleautomation
]
interface Converter : IDispatch {
[id(0x00000001), propget]
HRESULT Convert(
[in] double Value,
[in] BSTR CurrencyFrom,
[in] BSTR CurrencyTo,
[in, optional] VARIANT FullPrecision,
[in, optional] VARIANT TriangulationPrecision,
[out, retval] double* retval);
[id(0x00000002), propget]
HRESULT Version([out, retval] BSTR* retval);
};
};
am i lost ?
... yeah
|
|
|
|
|
You can look it up in the registry
Searching for msoeuro.dll under HKEY_CLASSES_ROOT gives us the CLSID {30A095E2-9A0C-11D2-93BB-00105A994D2C} and the ProgID MsoEuro.Converter.1 (data from Office 2000 SP3).
|
|
|
|
|
Woah !
Tricky.
But it works. Thanks !
(just need to find WHAT are the args, now)
-----------
"Always give me a new challenge to take up!"
|
|
|
|
|
Hello everyone. I need some help in writing a very simple OutProc multithreaded server in windows API only (not using any ATL wizard or sth.). I just finished normal singlethreaded component and figured out that I need multithreading support. I have no idea how to "enable" multihreading using my code written before. Does anyone know where can I find any materials or sample projects on this topic? Thanks in advance for your help!!
Greetings - TroLoo
|
|
|
|
|
Check out MSDN for examples. Also Search Google. I recommend these books on COM.
Inside COM (Programming Series) by Dale Rogerson
Developer's Workshop to COM and ATL 3.0 by Andrew Troelsen
Kuphryn
|
|
|
|
|
Does anyone know if neutral threading model doesn't work in in XP?
I seem to be getting different results depending on if I am in XP or windows 2000.
any hints?
|
|
|
|
|
Hi all, how can i change the dllhost appbase to look for assemblies in more directories than %system%\system32 and COM+ root directory.
Thanks.
|
|
|
|
|
I want to change a program id for a com project, so it will be different with the previous version.
Just change the .rgs file? or I need to change the uuid in idl files?
thanks
woody
|
|
|
|
|
Do you mean the prog ID string (eg MyServer.MyObject.1) or the CLSID ? If the latter, then you need to edit both. If the former, I think just the RGS, but I would change both anyway to avoid confusion.
Steve S
|
|
|
|
|
How do you configure a COM method and property so they have the same name? Specifically, we're building a browser application that extends the scripting world and needs to support the syntax:
window.external.Foo.setValue1("fred")
AND
window.external.Foo().setValue1("fred")
NOTE: For the record, if we controlled the JScript and could change it to conform to a single syntax we would.
The client has a bunch of JScript pages they don't control and an existing browser based application that needs to be replaced new application. They don't have access to the original developers or source code.
Thank you.
|
|
|
|
|
Looks like the JScript use the different flags of IDispatch::Invoke function in your cases.
/* Flags for IDispatch::Invoke */
#define DISPATCH_METHOD 0x1
#define DISPATCH_PROPERTYGET 0x2
#define DISPATCH_PROPERTYPUT 0x4
#define DISPATCH_PROPERTYPUTREF 0x8
The JScript uses the DISPATCH_PROPERTYGET flag in first case (window.external.Foo), and the DISPATCH_METHOD in second one (window.external.Foo()). For example, VBScript doesn't separate these cases and uses the DISPATCH_METHOD | DISPATCH_PROPERTYGET flag (which is valid).
As a rule, the default implementation of IDispatch will launch the existing function (either method or propget) in case of DISPATCH_METHOD|DISPATCH_PROPERTYGET. But it call only required function in case of DISPATCH_METHOD or DISPATCH_PROPERTYGET.
So the solution is the changing the passed flags from DISPATCH_METHOD or DISPATCH_PROPERTYGET into DISPATCH_METHOD | DISPATCH_PROPERTYGET and the calling of default Invoke-handler. Because the [propget] member and the [method] member with [retval] parameter are very similar.
HTH
With best wishes,
Vita
|
|
|
|
|
Hey, I've created an activeX Control which shows a modeless dialog. Now my Control should notify the containerapp when there a changes in dialogs items. I tried to send a message from my dialogclass to the parent (ControlClass) but nothing happend. How can I notify my ControlClass from within my DialogClass?
|
|
|
|
|
Use events (or Connection Point). You will find good article on Code Project or on the Net.
|
|
|
|
|
I am trying to query if a system has applications instantiated DirectShow video rendering objects.
Is there a way to query how many instances of any particular COM class is currently created on a system? (the instances may be owned by other applications).
If so, is there a way to interface with these created COM objects of another application?
Thanking in advance for a reply.
|
|
|
|
|
Not really. Over at sysinternalls, there are some tools with code, to show you how to view how processes have a loaded copy of a DLL. To get at a COM object of a DLL you need to be in the process to see them, in which case you can then hazard a guess at how many times the DLL has been locked, but then each COM object created adds a lock, so you can't be sure which.
I don't think COM was designed with these kind of metrics in mind.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
I know there have been numerous threads and articles regaring CString to BSTR conversion, but I can't seem to get the solutions given to work.
Here is what I have.
IN VB:
<br />
Private Declare Function GetNextCustomerID Lib "C:\Debug\DataAccess.dll" (CustomerID As String) As Long<br />
THEN:
<br />
Private Sub Form_Load()<br />
Dim TestStr As String<br />
Dim ret As Long<br />
<br />
ret = GetNextCustomerID(TestStr)<br />
If ret = 1 Then<br />
Label1.Caption = TestStr<br />
End If<br />
End Sub<br />
THEN, IN C++
<br />
extern "C" long __stdcall GetNextCustomerID(BSTR& CustomerID)<br />
{<br />
HRESULT hr = CoInitialize(0);<br />
long ret = 0;<br />
CString tmp;<br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
dbReferenceNums dbR;
if(dbR.Open())<br />
{<br />
if(!dbR.IsEOF())<br />
{<br />
tmp.Format("%s%d", "CX", dbR.m_NextAvailCustID);<br />
CustomerID = tmp.AllocSysString();<br />
ret = 1;<br />
}<br />
dbR.Close();<br />
}<br />
CoUninitialize();<br />
}<br />
return ret;<br />
}<br />
if the string is "CX1504", then the result that is printed in VB is "C" and that is all. I assume it is because a null character is encountered, because there is a null character between each character of the string. But, I can't figure out how to prevent this. I thought BSTRs were WCHAR-based strings and this behavior (nulls between each char) would be expected, but it is not interpretted correctly by VB.
Thanks in advance for any help you can provide.
raj.
|
|
|
|
|
Your issue is not connected with COM.
It's a way to call the DLL's function. VB simulate the parameter for you depending on its ANSI or UNICODE version.
ByVal xxx As String => TCHAR* xxx
ByRef xxx As String => TCHAR* *xxx as SysAllocStringByteLen does
You should use the VARIANT parameter instead.
With best wishes,
Vita
|
|
|
|
|
When calling a Declare d Sub or Function, VB6 ALWAYS translates a String into a null-terminated 8-bit char array (i.e. a normal C-style string of char ) - even if running on a Unicode-capable platform. If the string is passed ByRef it will be converted back on return.
What you should probably do is something like:
extern "C" long __stdcall GetNextCustomerID(char* CustomerID, long lSize)
{
long ret = 0;
dbReferenceNums dbR;
if(dbR.Open())
{
if(!dbR.IsEOF())
{
tmp.Format("%s%d", "CX", dbR.m_NextAvailCustID);
strncpy(CustomerID, tmp, lSize);
CustomerID[lSize] = '\0';
ret = 1;
}
dbR.Close();
}
return ret;
}
' VB code
Private Declare Function GetNextCustomerID _
Lib "C:\Debug\DataAccess.dll" _
(ByRef CustomerID As String, ByVal lSize As Long) As Long
Private Sub Form_Load()
Dim TestStr As String
Dim ret As Long
' Reserve space for string
TestStr = String(100, " ")
ret = GetNextCustomerID(TestStr, Len(TestStr))
If ret = 1 Then
Label1.Caption = TestStr
End If
End Sub VB does this because it has no knowledge of the parameters to the DLL function. If your C++ code was exposed as a COM object, VB would be able to obtain type information from the type library, and marshal data appropriately.
VB.NET users: the Declare statement functions as above, unless you specify the Unicode or Auto modifiers. For more control over marshalling, use the DllImportAttribute attribute.
|
|
|
|
|
well, I honestly feel like a complete idiot, but I cannot get this to work. I tried the code you listed above, but I receive an unhandled error (Access Violation) when control leaves my C++ DLL and returns to VB.
I have searched the internet and all the code sites I can think of to find a way to make this work. I can't find a single thing that will get this to work. I have many other functions that receive objects I have defined in VB classes, then the C++ code accesses a database, fills the properties of the object and then returns it to my VB exe. That all works fine. But, I cannot get the "simple" process of passing in a string, filling it, and returning it to VB.
arrrggggh!
Thanks anyway for your help.
I am stumped.
best regards
roger
|
|
|
|
|
Hello!
I want to implement simple COM object which will communicate with Oracle database somewhere on internet. It looks rather simple. But I have a possibility to use either C++ or C# technology. As I do not know C# very well: someone can help and put some comments - which technology would be simpler to write/manage ?
Or maybe there exists some ready-to-use sample?
Thanks for help
|
|
|
|
|
If you are creating a COM object, go with C++ and use ADO to talk to Oracle.
|
|
|
|
|
Hi,
I need to add a new method to my COM object.
Should I create a new COM object which aggregates the first and contains the new method?
Or is it OK to add a new method to an existing COM object?
Jeremy.
Jeremy Pullicino
C++ Developer
Homepage
|
|
|
|