|
Not sure what you want to do but let us try
a) Create an empty ATL or Com object called StringForMyBoss
b) Add to this object a property called value of type BSTR
c) Add to this object all the member functions designed in that class so you can use them from VB
Seems a bit overkill knowing that most of these functions exist in VB... but good luck!
Good luck,
Jerry
|
|
|
|
|
mmmhhh, slowly i think, i´m stupid..
i´ve try it and something works...well, in c++. i´m not ble to progamming vb and so, its the job of the boss.
you call it overkill? mmhh, boss said, in vb the stringoperations (esp. append) are too slow, c++ is more than faster...so enrico, you´re the trainee...create a dll that works for me...
i´ve never heard about this...and after more than 50 hours of searching you and another (from germany) helped me...in c++ it works, but in vb...well, it´s the boss´game
|
|
|
|
|
ok, i have a test dll...just returning a integer. in c++ it works, but what i have to do in vb?
these are 2 methods of the dll:
[cpp]
STDMETHODIMP CTesteMal::getInteger(int* i)
{
*i=666; //working
return S_OK;
}
STDMETHODIMP CTesteMal::getIntergerDieZweite()
{
int i=666; //working
return i;
return S_OK;
}
[/cpp]
in vb i´ve tried this:
[vb]
Private Sub TRY_Click()
Dim Zahl As TESTMITINTLib.TesteMal
Zahl.getInteger () 'here is an error
End Sub
[/vb]
it doesn´t work whats my failure?
|
|
|
|
|
Dear freund,
This VB Code
Dim Zahl As TESTMITINTLib.TesteMal
roughly means in C++:
ITesteMal * Zahl;
So you need to construct your object, like this
<br />
Dim Zahl As New TESTMITINTLib.TesteMal<br />
Dim x As Integer<br />
Zahl.GetInteger x<br />
Hope this does the trick!
J
|
|
|
|
|
thanks for your help but sorry, not working
the error messege is (hope, i translate it right):
error while compiling
argumenttype ByRef incompatible
//Edit: sorry, wrong error message....
the right is:
runtimeerror '438'
object does not support this property or method
i think, it would be better to give up :/
wish you a nice weekend...and i don´t want to sit in front of a pc before monday...
|
|
|
|
|
If you give up now, you will never make it!
VB Integers are actually C++ short
So you need to declare a VB long
Dim x as Long
Your week-end will be better after this...
BTW, thanks to you, I am humming Mozart's Requiem!
|
|
|
|
|
you´re really fast
i know, that i´m not allowed to give up, but...too long time for this theme :/ and here is nobody who can help me...no c++ programmer just me
and....the error comes again...perhaps it´s in my dll...mmmhh...but now, i´ll go home
if you´re interest in helping a newbee here is my icq-number
305531731
enrico
|
|
|
|
|
LacrimaMosa wrote:
you´re really fast
Yes that's what all my girlfriends said... not something I would have wanted to go public on the www... but never mind!
Not that much time to spare, if you have simple questions, I can try to help although VB + COM are not my area of expertise!
Good luck!
|
|
|
|
|
jerry .. naughty boy..... u shud have invited enrico to soapbox or Lounge to discuss these like stunning topics......
|
|
|
|
|
Ok, i´ve tested this and it works
Private Declare Function ReturnValue Lib "vbdll.dll" (ByVal lValue As Long) As Long
Private Declare Function ChangeValue Lib "vbdll.dll" (ByVal pValue As Long) As Long
Private Sub Command1_Click()
Dim lSendVal As Long
Dim lGetVal As Long
lSendVal = 100
lGetVal = 0
lGetVal = ReturnValue(lSendVal)
lSendVal = ChangeValue(lSendVal)
End Sub
-------------------------------------------------------
dll:
//nimmt einen wert und gibt ihn zurück
long __stdcall ReturnValue ( long lValue )
{
return lValue;
}
//erhöht den übergebenen wert um 100
void __stdcall ChangeValue ( long pValue )
{
(pValue) +=100;
}
-----------
now the problem are strings...i know, there ist a type mismatch between strings in c++ and strings in vb. but i don´t know the solution for this...something with BSTR. but in the way i´ve make my dll (look up) BSTR don´t work. somebody have a hint?
btw: @jerry: poor girlfriend-for her your surely too fast...so, bring her to me, you know how slow i am
|
|
|
|
|
I'm trying to create a program exposing it's interface to any third party software. No language limitations or assumption on the third party software can be made.The program is supposed to run as a service on a constant basis.
The program interface must reveal a way of reconfiguring/getting statistics from the program.
I'm wondering if anyone has an experience in the field of creating a program interface that will have following features:
1. Interprocess communication (Third party software will request/send information from/to my software)
2. Preferably will support remote usage. By a remote client.
One of the possible solutions is using a shared memory + event objects, but this is old and ugly approach.
Any suggestions with explanations,(COM?,COM+, DCOM?) will be highly appreciated.
|
|
|
|
|
You're looking at using DCOM.
Here's why (I might be partially wrong here):
COM: The start of COM, targets In-Process (DLL) application (Controls, etc).
COM+: Phase 2, targets out of process (Exe, Service, etc), mostly expands on OLE but makes its stronger.
DCOM: Targets remote server processes, which usually are services anyways.
DCOM is trickier to setup since you need to carefully define security and server to server security isnt easy unless you master it.
Note that its possible for a DCOM server to also act as out of process server if the caller is on the same system.
With DCOM, you need to create a COM Server that support remote calls, this add some constraints to you code but is easily controlled from the compilation of the IDL file. Then, you need to create a proxy/stub in process DLL that will run on the client system process. This stub will simply forward calls to the server using some communication protocol that you can define in "Component Services" administration applet, and then will get the replies back. If for some reason, you need callbacks, then the proxy part will catch server's calls to you process and forward them, therefore making it possible to get feedback from the DCOM server. btw, callbacks have a different name which i cant remember .. lol.
I would highly recommend that you start with a COM/COM+ application. Then, once you master the intricate details of COM, especially out of process specifics, you can mature to remote.
You can test COM/COM+ using VBA (Word, Excel, etc) or using IIS with vbscript or jscript. Note that creating an enumerator for jscript is much much more complex than it is for vbscript. I find VBA to be the simplest way to start seeing progress on your work. But IIS is easier to create sample user interface to test stuff, HTML helping here. Althought in your case, you probably just need VBA as the client.
|
|
|
|
|
I'm trying to create a program exposing it's interface to any third party software. No language limitations or assumption on the third party software can be made.The program is supposed to run as a service on a constant basis.
Any suggestions with explanations,(COM?,COM+, DCOM?) will be highly appreciated. .
Hi
COM, COM+ does not serve ur purpose of exposing an interface to a platform independent thirdparty remote client.
DCOM will do (still it is not platform independent), but it is the 20th centuary technology. Personally i won't prefer u 2 go 4 DOCM.
The 21st centuary solution for ur requirment is Webservices - the nextgen of DOCM.
If u r familiar with .NET this is just a one day work to create an XML web service in .NET. Any client app ( Sun OS, Mac OS, Linux or what ever ) can access ur service.
If .NET platform development is a concern, u can go for SOAP Webservices using SOAP toolkit . Then VB6/VC6 is enough, For this:
1) Install Microsoft SOAP Toolkit latest version on the server.
2) Just create a VB/ATL com dll with ur exposed interface, but the output of the method shud be SOAP format compatible XML text.
3) Generate the WSDL from the COM from using SOAP toolkit.
4) Expose the WSDL url as a webservice to the clients.
If u want more advanced, maintainable, scalable, distributed architecture go for SOA , Service Oriented Architecture . this is the most advanced of web services. I just mentioned for ur knowledge, no need to go for this. If u r a fresher to these techs it will take time to study SOA.
Simple Webservice is more than enough.
rgds..mil10
|
|
|
|
|
Is there a way to create a method in COM (developped in Visual C++) so I could use the operator = in VB?
In other words, once I have created my object in C++ I want to be able to write this in VB:
<br />
Dim Object1 As New MyObjectType<br />
Dim Object2 As New MyObjectType<br />
Object2 = Object1<br />
Is this possible?
Thanks in advance
|
|
|
|
|
Need to ask you a question:
Do you want Object2 to be a copy of Object1?
or Do you want Object2 to be the same instance as Object1 ?
Difference between the 2 is that, if you have a copy, you can then set both with different property values. Otherwise, if you change a property on Object1 then Object2 will have its property changed at the same time.
|
|
|
|
|
Hi DB,
I want Object2 to be a copy - an independent copy... I am no VB specialist but I think the way to do your no 2 is:
<br />
Set Object2 = Object1<br />
Thanks,
Jerry
|
|
|
|
|
Humm .. i dont know if this can be done, but while you wait for an answer, i would suggess you create a Method in your COM object that copies the content like:
Object1.CopyTo(Object2)
Seems like the best alternate solution to me
|
|
|
|
|
Yep this is indeed what I have done - a Clone method but I was hoping of something more elegant!
Well that was for some VB users so never mind
|
|
|
|
|
yes jerry, u and darkbyte are on the right track. There is no other way other than creating a method which returns another copy of that object.
One decoration that can be done to ur Clone method is, make it as the default method of the interface. For this goto the IDL defenition and change the DISPID to 0. then the vb cleint can call the clone nethod as:
dim a as new UrObject<br />
dim b as UrObject<br />
a(b)
Here a(b) will call ur default method clone
rgds... mil10
|
|
|
|
|
Exactly what I was looking for! Sir, you are a star!
|
|
|
|
|
Hi All,
How we can test performance of a COM dll? Do we have any tools shipped with Visual Studio? Any free tools on net?
Thanks & Regards
Neo
|
|
|
|
|
I have a project that was originally built in Visual Studio C++ 6.0. I have since upgraded to Visual Studio .NET and am encountering a link problem. The project is a (non-ATL generated)COM server that also employs templates that is built across 2 projects. The base class("PluginServ") implements the DllCanUnloadNow, DllGetClassObject, DllRegisterServer, and DllUnregisterServer. The .def file is in the aggregated class ("DerivedPlugin") project and declares the above exports.
The link error is the following:
------ Build started: Project: DerivedPlugInServ, Configuration: Debug Win32 ------
Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
DerivedPlugInServ.def : error LNK2001: unresolved external symbol DllRegisterServer
DerivedPlugInServ.def : error LNK2001: unresolved external symbol DllUnregisterServer
.\Debug/VPF.lib : fatal error LNK1120: 2 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
Build log was saved at "file://c:\projects\src\DerivedPlugInServ\Debug\BuildLog.htm"
DerivedPlugInServ- 4 error(s), 1 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped"
Anyone have any ideas as to how I may resolve this link error? I have looked online and have not come across a solution.
Thank you!
|
|
|
|
|
|
Hi! I'm trying to write a program that can grab the text from MS Word. This program will have to be seamless for the client, meaning the client can run a specialized program that creates it's own OLE instance of Word, so the only thing this program will have to go on is MS Word's HWND. According to the MSDN, if I can get the HWND for a class of _WwG, the inner-most window in Microsoft word, I can use AccessibleObjectFromWindow with OBJID_NATIVEOM as my object ID to get an IDispatch pointer to Word's COM model. The only trouble is, I have no idea what kind of object this points to. Is the Word.Application object, or Word.Document? Also, using GetIDsOfNames on this IDispatch interface never works, even for the must-have functions like QueryInterface and AddRef! Maybe someone could help me with this, I would really appreciate it, thanks!
-java
|
|
|
|
|
shameless bump
|
|
|
|
|