Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Application Name

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2008, 07:10 AM
Junior Member
 
Join Date: Jan 2008
Posts: 14
Smile Application Name

Is it possible to use the coding to retrieve the name of the application?

For example, the application is named as MyApp.exe.

We can write somethings like

MsgBox(AppName())

and it will prompt up "MyApp.exe" insides the Messagebox.

Tks.
Reply With Quote
  #2 (permalink)  
Old 02-12-2008, 09:38 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi kawawong, welcome b4ppc forum!

Not totally sure what you are after, but 'filesearch' statement may help.
Example:
Code:
    'first create control arraylist al1 on the form.
FileSearch(al1,AppPath,"*.exe"'gather all exe files from application directory and assign file list to arraylist 'al1'.

'you can display each file names excluding file path something like:

For i = 0 To al1.count-1  
Msgbox(SubString (al1.item(i), StrLength(AppPath)+1,StrLength(al1.item(i))+1-StrLength(AppPath)))
Next

Regards,
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB

Last edited by Rioven : 02-12-2008 at 11:09 AM. Reason: corrected
Reply With Quote
  #3 (permalink)  
Old 05-08-2012, 08:04 AM
Newbie
 
Join Date: Apr 2012
Posts: 5
Default AppName like AppPath?

I searched the forums... w/o satisfied result.

I would need the AppName (MyApp.exe) so that I would be able to open then the settings file (MyApp.ini) and the default text file (MyApp.txt).

Knowing all .exe inside AppPath folder... isn't a real help, since there can and will be more .exe files.

To some of you knowing .NET... could I find something there?

Thank you for ANY help/answer.

Best regards,
Ionut Ojica

Last edited by ionutojica : 05-08-2012 at 08:07 AM. Reason: Notifications enabled of thread
Reply With Quote
  #4 (permalink)  
Old 05-08-2012, 08:43 AM
Jost aus Soest's Avatar
Basic4ppc Veteran
 
Join Date: Mar 2012
Location: Soest, Germany
Posts: 222
Default

What's about Activity.Title?
Reply With Quote
  #5 (permalink)  
Old 05-08-2012, 09:50 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Activity.Title
Wrong forum - this is about Windows Mobile, hence the reference to an exe file..

Unfortunately there is no way I can think of, even using reflection, to obtain the actual filename as all compiled Basic4ppc assemblies (exe) have the actual assembly name of "1" (which can be obtained by the Door library but is not of much use) and are renamed after compilation to match the project name. It is easy to get the actual filename on the desktop but the Compact Framework lacks that ability and a P/Invoke to native code is the only way I have found so far that will work on a device.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 05-08-2012 at 10:32 AM.
Reply With Quote
  #6 (permalink)  
Old 05-18-2012, 09:51 AM
Newbie
 
Join Date: Apr 2012
Posts: 5
Default Workaround

The simplest workaround I suppose would be to pass the file name as an argument to the program.
And so, in a folder could be many files with their shortcuts, inside the shortcuts would be the link to the file and the file name as an argument.
Not the right way... but it works for sure.

Quote:
It is easy to get the actual filename on the desktop
Could I ask how? Thanks in advance.

Quote:
P/Invoke to native code
I have searched and found informations about this here:
An Introduction to P/Invoke and Marshaling on the Microsoft .NET Compact Framework

To find the solution would take me around a week... for the moment I choose the first way.

Best regards,
Ionut Ojica
Reply With Quote
  #7 (permalink)  
Old 05-18-2012, 10:23 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Code:
System.Reflection.Assembly.GetEntryAssembly().Location
or

Code:
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
or

Code:
System.Windows.Forms.Application.ExecutablePath
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #8 (permalink)  
Old 05-18-2012, 10:37 AM
Newbie
 
Join Date: Apr 2012
Posts: 5
Default

Thank you for the fast answer.

Oh, so none of them work on Device... but on Desktop they give the right path with file name.
Code:
Sub App_Start
 Form1.Show
 obj.New1(
False)
 oProcess.New1(
False)
 Method3
End Sub

Sub Method1
 
'System.Reflection.Assembly.GetEntryAssembly().Location
 obj.CreateNew("System.Reflection.Assembly" & obj.System_Mscorlib)
 obj.Value = obj.RunMethod(
"GetEntryAssembly")
 label1.Text = obj.GetProperty(
"Location")
End Sub
Sub Method2
 
'System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName:
 oProcess.CreateNew("System.Diagnostics.Process" & oProcess.System_NS)
 oProcess.Value = oProcess.RunMethod(
"GetCurrentProcess")
 obj.CreateNew(
"System.Diagnostics.ProcessModule" & oProcess.System_NS)
 obj.Value = oProcess.GetProperty(
"MainModule")
 label1.Text = obj.GetProperty(
"FileName")
End Sub
Sub Method3
 
'System.Windows.Forms.Application.ExecutablePath
 obj.CreateNew("System.Windows.Forms.Application" & obj.System_Windows_Forms)
 label1.Text = obj.GetProperty(
"ExecutablePath")
End Sub

Last edited by ionutojica : 05-18-2012 at 11:29 AM.
Reply With Quote
  #9 (permalink)  
Old 05-18-2012, 11:37 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by ionutojica View Post
Oh, so none of them work on Device
That's what I said before.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
GPS application - Part I Erel Tutorials 22 09-11-2010 10:07 AM
My first application Erel Tutorials 16 04-18-2010 08:09 PM
Minimize Application akr Questions (Windows Mobile) 5 08-15-2009 10:05 PM
application already running micro Questions (Windows Mobile) 3 09-04-2008 09:20 AM
DB Application scott93727 Share Your Creations 0 05-02-2007 05:24 AM


All times are GMT. The time now is 01:57 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0