FB-compiled executable with a unicode name

New to FreeBASIC? Post your questions here.
newbieforever
Posts: 84
Joined: Jun 21, 2018 11:14

FB-compiled executable with a unicode name

Postby newbieforever » Jul 10, 2018 8:47

I apologize a lot, I am quite confused: Has there already been a solution for this in your tips?

MyApp.exe is a FB-compiled file. In the code of the file are the following three lines which extract the name of the program ('MyApp'):

Code: Select all

Dim As Wstring * 500   appn = Command(0)
appn = Mid(appn, InStrRev(appn, "\") + 1)
If Instr(appn, ".exe") Then appn = Left(appn, len(appn) - 4)

That works fine, of course, appn is set to 'MyApp'.

However, the above code lines don't work if MyApp.exe is renamed to MyAppč.exe: the unicode character is lost, appn is set to 'MyAppc'!

Has this problem already been solved here?
newbieforever
Posts: 84
Joined: Jun 21, 2018 11:14

Re: FB-compiled executable with a unicode name

Postby newbieforever » Jul 10, 2018 11:41

What a joy! It takes a load off my mind. Has already been solved here by one of you!

Code: Select all

Dim As Wstring * 10000 cmdl = *GetCommandLineW()
Dim As Long            narg
Dim As Wstring Ptr Ptr argl = Cast(Wstring ptr ptr, CommandLineToArgvW(cmdl, @narg))
Dim As Wstring * 500   appn = *argl[0]
appn = Mid(appn, InStrRev(appn, "\") + 1)
If Instr(appn, ".exe") Then appn = Left(appn, len(appn) - 4)
Print appn
Last edited by newbieforever on Jul 10, 2018 16:55, edited 1 time in total.
newbieforever
Posts: 84
Joined: Jun 21, 2018 11:14

Re: FB-compiled executable with a unicode name

Postby newbieforever » Jul 10, 2018 11:53

PS: PaulSquires was it!

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 3 guests