We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Problems with command line arguments

gem56
gem56 asked
on
Medium Priority
243 Views
Last Modified: 2010-04-07
Hi guys,
I'm having problems with command line arguments. When I double click on a file (p1.gemr) on my Desktop, my application uses the following statement to read the command line parameters, wanting to extract the above file name:

     sFileName = Replace(Command, """", "")

Instead of getting a proper file path+name I get what appears to be a truncated name, e.g.

     C:\DOCUME~1\michael\Desktop\P165E9~1.GEM

I imaging it has something to do with short file names but I don't know how to check/set that.
Does anyone have any ideas as to how to solve my problem?

/Michael
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
to get the application path, use
app.path

Author

Commented:
What I'm really after is the name of the file that was opened, so that my application can read the contents.

/Michael
have you tried opening it using exactly what was returned.  i.e., even though we don't know what "DOCUME~1" really refers to, it should still be a valid path.  Unfortunately I don't have a system I can test this on, so it's just a guess.

Commented:
Have you tried converting the short filename to a longfilename?

Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long

Private Function fGetLongPath(strShortPath As String) As String
Dim strLongPath As String, lngRet As Long
strLongPath = Space$(255)
lngRet = GetLongPathName(strShortPath, strLongPath, 255)
fGetLongPath = Left$(strLongPath, lngRet)
End Function


Private Sub Command1_Click()
   MsgBox fGetLongPath(sFileName)
End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks everyone for your input, especially vinnyd79 as that did the trick.

/Michael
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.