May 05, 2024, 02:20:23 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


how to get exename ?

Started by zaphod, October 30, 2009, 02:59:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zaphod

The function getstartpath get the path of executable. Ok.
I need also the name of executable for save a ini file with same name (even if user modify name)...
Is it possible ?

Ionic Wind Support Team

Use the API function GetModuleFileName

DECLARE "kernel32",GetModuleFileNameA(hmod as UINT,path as STRING,length as INT),INT
string name
GetModuleFileNameA(0,name,255)
print name
Ionic Wind Support Team

zaphod

hello,
thanx very much.

here is my code if could help someone :

                def name as STRING
DECLARE "kernel32",GetModuleFileNameA(hmod as UINT,path as STRING,length as INT),INT
name=SPACE$(255)
getmodulefilename(0,name,255)
name=extractfilename(name)


and filename functions :


sub extractfilename(fname as string),string
                def q,p=1 as INT
DO
q=instr(fname,"\\",p)
if q
p=q+1
ENDIF
until q=0
return right$(fname,len(fname)-p+1)
ENDSUB

sub extractfilepath(fname as string),string
                def q,p=1 as INT
DO
q=instr(fname,"\\",p)
if q
p=q+1
ENDIF
until q=0
return LEFT$(fname,p-1)
ENDSUB


Maybe its a good idea to insert into EB some filename functions.
In Pure Basic there is : GetFilePart / GetPathPart
In BlitzMax : StripDir$ / StripExt$/ ExtractDir$ / ExtractExt$

LarryMc

November 01, 2009, 06:34:26 PM #3 Last Edit: November 01, 2009, 06:40:59 PM by Larry McCaughn
Those functions and more are available in Fletchie's "ctl.lib"

You can download it here:

http://www.ionicwind.com/forums/index.php/topic,1608.msg15133.html#msg15133

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

zaphod

Thanx for the ctl.lib : sounds good.
Must be include into EB...