Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another c++ to VB question

Status
Not open for further replies.

ADoozer

Programmer
Joined
Dec 15, 2002
Messages
3,487
Location
AU
this thread is related to thread222-505842, started by EwS

my question relates to converting a not known data type from C++ to VB.

the thread in question is asking about the CERAPIInvoke function (which i understand is something to do with windows CE, a topic i know nothing about)

The following is info gathered from MSDN and the internet!!

CERAPIInvoke declaration (C++)

HRESULT STDAPICALLTYPE CeRapiInvoke(LPCWSTR lpwszDll,
LPCWSTR lpwszFunc,
DWORD dwInputCount,
LPBYTE pcbIn,
WORD *pcbOutput,
LPBYTE *ppbOutput,
IRAPIStream *ppStream,
DWORD dwReserved)


now most of this is pretty standard to convert to VB {i]except[/i] the IRAPIStream bit...

now again from MSDN:-

IRAPIStream *ppStream is a pointer to the adress of a IRAPIStream interface

the IRAPIStream interface has two methods SetRAPIStat and GetRapiStat

SetRapiStat(
RAPISTREAMFLAG Flag,
DWORD dwValue);

GetRapiStat(
RAPISTREAMFLAG Flag,
DWORD *pdwValue);


my suggestion to was as follows:-

public Type SetRAPISTAT
RapiFlag as boolean
dwVal as long
end type

public type GetRAPISTAT
RapiFlag as boolean
pdwVal as Long
end type

public type IrapIStream
SetRAPI as setRapistat
getRAPI as getRapistat
end type

dim StructureToSend as IrapIStream

now assuming my above assumption was correct (which im not sure it is) How would i/we pass this parameter to a c++ dll (ie byref, byval)

if anyone can provide some input you will help me understand converting C++ dlls more and solve EwS problem in one shot!

any input greatly appreciated!!

(on a side not i will make sure this thread is linked to all previosly started threads on this subject!..[all 4 of them] LOL) If somethings hard to do, its not worth doing - Homer Simpson
 
If it's an interface pointer, it's way simpler in VB than you think. You're already doing it all the time (probably without even knowing you do, because VB is very good in hiding that for you): They're objects. Just set a refence to the COM server in question and then:

Dim objRAPI as IRAPIStream
Set objRAPI = New IRAPIStream

I don't know anything about this CE stuff either, so I cant' tell you is the above is te correct way (usually there are objects in the server that are named different than their interfac(es). It might also be something like the following:

Dim objRAPI as SomeObjectInServer
set objRAPI = New SomeObjectInServer

Now, if IRAPIStream is the default interface of the SomeObjectInServer object, VB will create the SomeObjectInServer object for you and hand you a pointer to the IRAPIStream interface (VB will always automatically hand you a pointer to the default interface of an object when you ask it to create an object for you).


On the other hand, if IRAPIStream is not the default interface of the SomeObjectInServer object, it would have to be something like this:

Dim objRAPI as IRAPIStream, objOBJECT as SomeObjectInServer
Set objOBJECT = New SomeObjectInServer
Set objRAPI = SomeObjectInServer

And maybe (I'm not sure how VB handles this below the surface, but in C you can directly ask for another than the default interface pointer when creating an object), it can also be done like this:

Dim objRAPI as IRAPIStream
Set ObjRAPI = New SomeObjectInServer
Greetings,
Rick
 
the more i read on this subject the less i know!!!!

>Dim objRAPI as IRAPIStream

so presumably you would need to set a reference to something to have this in your list of objects?!?!

>if IRAPIStream is the default interface of the SomeObjectInServer object

i think it is but im not gonna put money on it!!

thanks for the input, If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top