Results 1 to 3 of 3

Thread: A string you say!?

  1. #1

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

    A string you say!?

    Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!

    How hard is it to pass a string from one place to another without getting the BSOD!!!! Could anybody here give me a very simple program that will pass a string to a VC++ dll and then modify it and pass it back?? Thats all.

    This is what im trying to do (but the not-so-good computer keeps crashing me for trying to do "illegal" things):

    Code:
     ' Visual Basic
     Public Declare Function SayHello (  ByRef lpString As String, 	' char*
                                         ByRef lpLong As Long, 	' int*
                                         ByVal nLong As Long, 	' int
                                         ByVal lpFunc As Long 	' Complicated :)
                                         ' Pointer to function: int foo(void*, int*, int)
                                      ) As Long
    
     ' The callback part is for emulating an "Event" in VB.
     ' The Event has to be of the form:
     ' foo(byref a as object, byref b as long, byval c as long) as long
    
     ' temp callback...
     Public Function cbFoo( Obj as udtMyUdt, count as long, byval max as long ) as long
    
     // Visual C++
     // First the callback definition (to make things easier)
     typedef int (*fnCallBack) (void*, int*, int)
    
     int SayHello ( char* lpstr, int* lpn, int n, fnCallBack f) {
       strncpy(lpstr, "Do you yahoooo!!", n);
       (*lpn) ++; // Ignore this... just changing the value of lpn
       return f( lpstr, lpn, n); // Ignore; this will "call the event"
     }
    Please ignore all of the "mumble-jambo" that u see in there... i just want to be able to pass a string to vc and be able to alter that string...

    EVERYONE that i asked told me a different answer that always seems to crash my program so please dont hesitate, im at the point where i will try ANYTHING (NOT including COM or ATL or MFC)!!

    Thanks in Advance.
    :MoMad:
    Nice Sig!

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

  2. #2
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    I dont' know if this a reasonable suggestion but...

    A rather roundabout way of doing it could be to place an invisible textbox on your form. Then, using findwindow and findwindowex, you place in the c++ a SendMessage to the handle of the textbox using wm_gettext and an lparam of your string. This will get you your string. Then once you have it, you can manipulate it and send the altered text back using SendMessage wm_settext witht he lparam of your string. Then, in the textbox change event, you can monitor when the string was recieved and handle the string at that point. I don't know if this is helpful, but I hope it is.

    Joe

  3. #3

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

    To tell you the truth, Im trying to stay as far away from ATL/COM/MFC or any combination of them. And so far, Ive got nothing but those three... so I finally decided to use a little of ATL to get the correct results. A little ATL wouldn't hurt my project will it?? nah!!

    Anyways, Thanks very much for the response, I also posted here:

    http://www.vbforums.com/showthread.p...hreadid=129411

    And got a response within the hour... because I thought this thread was dead since no one was on it at the time... but after a while, it came clear... a little ATL will not hurt me!!

    Regards,
    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