[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Problems with command line arguments

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
0
gem56
Asked:
gem56
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
to get the application path, use
app.path
0
 
gem56Author Commented:
What I'm really after is the name of the file that was opened, so that my application can read the contents.

/Michael
0
 
g_johnsonCommented:
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.

0
 
vinnyd79Commented:
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
0
 
gem56Author Commented:
Thanks everyone for your input, especially vinnyd79 as that did the trick.

/Michael
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now