Results 1 to 4 of 4

Thread: Strings are deadly...

  1. #1

    Thread Starter
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625

    Strings are deadly...

    ... Cuz the killed my app!

    I really need help on this and the API is dead so please someone point me in the right direction.

    http://www.vbforums.com/showthread.php?threadid=129405
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    VC++ is a second language to me so there may be a better way, but here is how I do it.

    'VB Code
    VB Code:
    1. 'Module
    2. Option Explicit
    3. Public Declare Function SayHello Lib "test.dll" (ByVal lpString As String, ByVal MyInt As Long, ByVal lpFunc As Long) As Long
    4. Private Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As String, lpString2 As Any) As Long
    5.  
    6.  
    7.  Public Function cbFoo(Obj As Long, count As Long) As Long
    8.     Dim sInBuffer As String
    9.     sInBuffer = Space$(1024)
    10.     Call lstrcpy(sInBuffer, Obj)
    11.     Debug.Print sInBuffer
    12.  End Function
    13.  
    14. 'Form
    15. Option Explicit
    16.  
    17. Private Sub Form_Load()
    18.     Dim lpString As String, MyInt As Long, lRet  As Long
    19.     lpString = Space$(1024)
    20.     lRet = SayHello(lpString, MyInt, AddressOf cbFoo)
    21. End Sub

    VC++ Code
    Code:
    'CPP File
    #include <windows.h>
    #include <stdio.h>  
    
    typedef void (__stdcall *fnCallBack)(LPTSTR lpszOutPut, long lpn);
    fnCallBack ReturnCB;
    		
    
    __declspec( dllexport ) int WINAPI SayHello (LPSTR StringIn, long lpn, long f) {
    	ReturnCB = (fnCallBack)f;
    
    	strcpy(StringIn, "Why do you yahoooo!!");	
    	(lpn) ++; 
    	ReturnCB(StringIn, lpn);
    	return 1;
     }
    
    'DEF File
    LIBRARY Test
    DESCRIPTION 'Test.dll'
    
    EXPORTS
    
    ; DLLXPORT_BEGIN:
    
      SayHello
    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3

    Thread Starter
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Thank you so much greg, that saved my day. I already tried this method and it did not work... I have searched and searched and no answer...

    I wanted to stay as far away from ATL/COM/MFC but it seems that they are necesary in order for me to finish this on time. Please let me know if you find anything else. It will help alot.

    -MoMad
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  4. #4

    Thread Starter
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Ha!!! I found the sollution!!

    To ANYONE HAVING PROBLEMS WITH THIS SUBJECT:

    HERE IS THE SOLLUTION!!

    CLICK>>>>
    http://www.codeproject.com/dll/superdll.asp
    >>>CLICK

    MoMad
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width