πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programmer.tools.mfc
3 messages
3 total messages Started by iti Wed, 27 Mar 1996 19:54
HELP !!! WIth VB & DLL connection
#67
Author: iti
Date: Wed, 27 Mar 1996 19:54
15 lines
1105 bytes
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.

I would appreceate it if you can also answer me directly.  My E-Mail address is
iti@net.netvision.il

Thanks alot for all your help
Yaakov
Re: HELP !!! WIth VB & DLL connection
#72
Author: Helge Süß
Date: Tue, 09 Apr 1996 09:13
43 lines
2167 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
----------------------------------------------------------
Re: HELP !!! WIth VB & DLL connection
#73
Author: 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
----------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads