Advertisement
ascend4nt

Get Executable Filename - FreeBASIC

Jan 3rd, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _UNICODE 1
  2. #define UNICODE 1
  3. #include "windows.bi"
  4.  
  5. '' Author: Ascend4nt
  6.  
  7. Function ExeName() As WString Ptr
  8.   Dim sExeName As WString * MAX_PATH
  9.   Dim nLen As Integer
  10.   Dim sRet As WString Ptr
  11.   nLen = GetModuleFileName(NULL, sExeName, MAX_PATH)
  12.  
  13.   sRet = Allocate( (nLen + 1) * Len(WString) )
  14.   If nLen = 0 Then
  15.       *sRet = ""
  16.   Else
  17.       *sRet = sExeName
  18.   End If
  19.   Return sRet
  20. End Function
  21.  
  22. '' == MAIN ==
  23.  
  24. Dim sFileName As WString Ptr
  25. sFileName = ExeName()
  26.  
  27. MessageBox(0, !"Filename:\n" + *sFileName, "Name of Executable", MB_OK Or MB_ICONINFORMATION)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement