OLE help for newbie

Tech-Archive recommends: Fix windows errors by optimizing your registry



I program a lot of stuff in ASP and VB. I needed an application that
could run on a server, handle data and be manipulated by VBScript or
something similiar. I decided to take a crack at writing a VC++ OLE
server. I can do all the C++ stuff I need to, but when it comes to the
OLE server I keep running into walls. I've gotten to the point where I
used the wizard to create the type library and method. Say I have these
two methods in the type library:

[id(4), helpstring("method TEST4")] HRESULT TEST4([out] DOUBLE* TestD);
[id(6), helpstring("method TEST6")] HRESULT TEST6([out] BSTR* TVAL);

And they're implimented like this:

STDMETHODIMP CLOUSDB::TEST4(DOUBLE* TestD)
{
AFX_MANAGE_STATE(AfxGetAppModuleState());
CString ShowS;
ShowS=System::Convert::ToString(TestD->ToString());
MessageBox(NULL,(LPCSTR) ShowS,"hi", MB_OK);
*TestD=(DOUBLE) 4;
return S_OK;
}

STDMETHODIMP CLOUSDB::TEST6(BSTR* TVAL)
{

AFX_MANAGE_STATE(AfxGetAppModuleState());

return S_OK;
}

Then in VB6, I have:

Dim TEST As LOUSDB
Set TEST = CreateObject("DB2.LOUSDB.1")
Dim TestDbl As Double
a.TEST4 TestDbl
a.TEST6 TestStr$

Now, for TEST4 this will show the value of TestDbl in a message box.
For TEST6, nothing happens. What I want to do, however, is change the
values of the variables in VB6. After passing TestDbl into the
function, I want it to equal something else. I would like TestStr to
equal something like "Hello" for now, just so I can understand how this
all works.

Any help would be greatly appreciated. At some point, I'll buy a book
or something but right now I'm just trying to see how far I can get by
tinkering. It usually works ok for me. Thanks.

P.S. If I have [out,retval] in the type library, VB6 won't allow me to
pass any arguments. Why? I need this to work in ASP, so I always
figured that VB6 was closer to VBScript.

.



Relevant Pages

  • Re: OLE help for newbie
    ... could run on a server, handle data and be manipulated by VBScript or ... Dim TestDbl As Double ... values of the variables in VB6. ... figured that VB6 was closer to VBScript. ...
    (microsoft.public.vc.mfc)
  • Re: can run javascript cant run vbscript - WHY
    ... client-side VBScript. ... >processing/formatting is done on the server, ... What you will need to do is set a "flag" on the client side, ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: can run javascript cant run vbscript - WHY
    ... >> see any reasoning behind the posts, for that, I apologize. ... > about client-side VBScript. ... >>I think you are confusing my response with a response post later. ... > and during the server processing of the form's postback, ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: can run javascript cant run vbscript - WHY
    ... It is part of the window object in the HTML DOM. ... >alert method from within a vbscript tagged script block. ... VBScript is client-side, ... and during the server processing of the form's postback, ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: Launch batch file and pass control back to VBScript
    ... StartTime = Timer() ... This VBScript, configured to run when the server reboots, is designed ... How can I configure the VBScript or the batch file it launches to ...
    (microsoft.public.scripting.vbscript)