πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools.mfc
Article #73

Re: HELP !!! WIth VB & DLL connection

#73
From: Helge Süß
Date: Tue, 09 Apr 1996 09:13
43 lines
2141 bytes
iti@Jerusalem.netvision.net.il wrote:
>
>I have a DLL written in Visual C++ and am trying to write a Visual Basic (Ver. >3) application to use it.  I am new to VB so I have two questions.
>
>	1.  How can I access the message que (in order to do my own message >processing) in a VB application?
>
>	2.  I have a C DLL function declaired as 
>"char far*   WINAPI    _export    MyFunct(void)  ".  How do I declare it in VB.
>

Declare Function MyFunct Lib "MyDll.DLL" As Long

You won't be happy with the char* though because VB Strings are handled
in a VERY different way. If you want to return a string result pass a
pointer to the function and a pre-initialized string at runtime.

e.g. int WINAPI _export MyFunct(char* result);

Declare Function MyFunct Lib "MyDll.DLL" (ByVal result As String) As Integer

(if you want to return a negative error code as function result in the int
or the length of the string if successful)

Then call it like this:

Dim ok As Integer
Dim resultstring As String

resultstring = "lotsofspacesuptothemaxyou'llexpect" & chr$(0)
ok = MyFunct(resultstring)
If ok >= 0 Then
    resultstring = Left$(resultstring, ok)
Else
   ' got some error to report
End If

Helge ;-)=)

----------------------------------------------------------
      (c) All Thoughts are Mine -- Genuine Genius
----------------------------------------------------------
helge@siemens.co.at        -----         VIENNA -- AUSTRIA
----------------------------------------------------------
Technical Details
Message-ID: <4kd9ol$o15@news.siemens.at>
Path: arc1-ca.pugleaf.net!siemens.at!usenet
References: <NEWTNews.31178.827960329.Postmaster@Jerusalem.netvision.net.il>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!siemens.at!usenet
From: "Helge Süß" <helge@siemens.co.at>
Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.lang.c++,comp.lang.basic.visual.database,comp.lang.basic.visual
Subject: Re: HELP !!! WIth VB & DLL connection
Date: 9 Apr 1996 09:13:57 GMT
Organization: Siemens AG Austria
Message-ID: <4kd9ol$o15@news.siemens.at>
References: <NEWTNews.31178.827960329.Postmaster@Jerusalem.netvision.net.il>
NNTP-Posting-Host: pc5888.hil.siemens-austria
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.22 (Windows; I; 16bit)