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.


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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
to get the application path, use
gem56Author Commented:
What I'm really after is the name of the file that was opened, so that my application can read the contents.

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.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gem56Author Commented:
Thanks everyone for your input, especially vinnyd79 as that did the trick.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.