Loading ...
Sorry, an error occurred while loading the content.

Re: [libertybasic] another calldll

Expand Messages
  • Marc Rossi
    Thanks ,  Stefan.  I appreciate you going over that for me. Marc ________________________________ From: Stefan Pendl To:
    Message 1 of 5 , Jun 15, 2013
    • 0 Attachment
      Thanks ,  Stefan.  I appreciate you going over that for me.
      Marc


      ________________________________
      From: Stefan Pendl <pendl2megabit@...>
      To: libertybasic@yahoogroups.com
      Sent: Saturday, June 15, 2013 5:51 AM
      Subject: Re: [libertybasic] another calldll

       

      Am 15.06.2013 11:30, schrieb Marc Rossi:
      > This is what I came up with but I still can't get it to function right. Help?
      > ' code start
      > st$ = "quad.exe"
      > F$ = GetModuleFileNameA$( 15, st$, 275, 0)
      > print F$
      > File$ = space$(255) + chr$(0) ' buffer to receive file
      > Length = len(File$)
      >
      >
      > function GetModuleFileNameA$(task, File$, Length, result)
      > calldll #kernel32, "GetModuleFileNameA",_
      > task as ulong,_ ' task handle from load library
      > File$ as ptr,_ ' buffer to receive filename
      > Length as ulong,_
      > result as ulong
      > GetModuleFileNameA$ = File$
      > end function
      > ' code end
      >

      This is how the API function would be wrapped for LB.

      hModule, the handle to the module, would be retrieved by the
      GetModuleHandle API function and passed to the GetModuleFileName API
      function.

      If hModule is 0 (=zero) the file name of the executable of the current
      process is retrieved.

      '---code start (watch for line wraps)

      function GetModuleFileName$(hModule)
      ' return the full path of the executable specified by its handle

      nSize = _MAX_PATH + 1
      lpFilename$ = space$(nSize); CHR$(0)

      calldll #kernel32, "GetModuleFileNameA",_
      hModule as uLong,_
      lpFilename$ as ptr,_
      nSize as uLong,_
      result as uLong

      if result > 0 then GetModuleFileName$ = trim$(lpFilename$)
      end function

      '---code end

      --
      Stefan Pendl
      http://stefanpendl.runbasichosting.com/

      LB 4.04 Pro ... http://www.libertybasic.com/assist.html
      LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

      LB Community Wiki .............. http://basic.wikispaces.com/
      LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
      LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit SP1
      AMD Turion X2 RM-70 2GHz, 4GB RAM



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.