retrieving name of the executable ?

pano

Member
Licensed User
Hello guys,

args(0) does not give the name of the executable alike in C.

apppath give the path without the exe name.

Any idea to retrieve the .exe name ?

a little explanation : my goal is to copy the same exe with different names for launching them with voicedial, and after the exe has retrieved his own name, it will push it in the registry and activate another always running prg that, on feeling activated, will get the registry parameter and do something.

Looks complicated but will end up like this :

after launching voicedial with the PTT button on the wired headset of my HTC Artemis : I say "next" and my own mp3 player will play the next song.

so easy :)

Thanks for any idea, I will try. René
 

moster67

Expert
Licensed User
Longtime User
If this is not your scenario, then please disregard.

I am afraid this can't be done in Basic4ppc nor in the CF.NET.

However, I found this article, using P/Invoke - Peter Foot - Get the name of your executing .exe.

Maybe you could write a library in order to get it to work in Basic4ppc although I am not sure if it would work (I have some doubts as to P/Invokes used in external libraries and if they work in Basic4ppc).

Good luck.
 

eww245

Member
Licensed User
If this is not your scenario, then please disregard.

I am afraid this can't be done in Basic4ppc nor in the CF.NET.

However, I found this article, using P/Invoke - Peter Foot - Get the name of your executing .exe.

Maybe you could write a library in order to get it to work in Basic4ppc although I am not sure if it would work (I have some doubts as to P/Invokes used in external libraries and if they work in Basic4ppc).

Good luck.

PInvoke does work with external libraries.
Just about everything in DotNet can be used in b4p.

As for as the executable name unfortunately all exe's true assembly name is 1.exe in b4p.
Though this can be changed with ResHacker, along with version, copyright, and anyother file info.
Then using Peter Foots example should do the trick.
I havent tried his method, but have had good luck with his code.

Another option would be to build an array of the file names in the AppPath directory.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've attached a small library which returns the name of the executable.

Libraries developers: One thing interesting about this library is that it first checks the value of cPPC which is loaded by Basic4ppc to the thread storage and then invokes the correct method. So this library works on the desktop and on the device (the source code is included).

Setup instructions: copy both files to Basic4ppc libraries folder:
C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries

Edit: Forgot to write that this code is based on Peter Foot blog: Peter Foot - Get the name of your executing .exe
 

Attachments

  • ExecutableName.zip
    2.8 KB · Views: 32

pano

Member
Licensed User
Incredible ! Same things as if the Lamborghini chief ingeneer added a second rear speed to my (dreamed) Countach just on suggestion ! Thanks all guys :sign0008:

Btw perhaps this info will help or give sb some idea : when you long press the button on the wired headset it run SPPdialer.exe for the voice dialer function and on a double press it runs redial.exe for recalling the last number.

Guess what ? you can replace them with your own B4P exe. I actually use only redial.exe. As my soft (a mix of a GTD notes/lists manager and mp3 player) knows what he is doing when activated by the double press, it can do many different things related to the context with just this button.
 

Byak@

Active Member
Licensed User
Big thanks Erel =)
 
Top