[Help] Full paths / short paths |
Author: |
Message: |
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
Joined: May 2004
Status: Away
|
O.P. [Help] Full paths / short paths
Is there any way I can convert a short path into a long one in JScript? I have a function that returns:
C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
But I need the full proper path, I've search and searched, but I'm outta ideas.
Anybody?
|
|
07-05-2006 04:55 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Full paths / short paths
you will want to use GetFullPathNameW api if i remember correctly
This post was edited on 07-05-2006 at 05:11 PM by matty.
|
|
07-05-2006 05:10 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
Joined: May 2004
Status: Away
|
O.P. RE: RE: [Help] Full paths / short paths
quote: Originally posted by Matty
you will want to use GetFullPathNameW api if i remember correctly
I was trying that, but it seems to require I pass it some StringBuilder type which doesn't seem to exist in JScript or something. If you could show me an example, that'd be very useful.
|
|
07-05-2006 05:13 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Full paths / short paths
Again I am at work can't test it
code: function ConvertPath(sString){
var MAX_PATH = 260;
var sBuffer = Interop.Allocate(2*(MAX_PATH)+2);
Interop.Call('kernel32', 'GetFullPathNameW', sString, MAX_PATH, sBuffer, '');
return sBuffer.ReadString(0);
}
|
|
07-05-2006 05:22 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
Joined: May 2004
Status: Away
|
O.P. RE: [Help] Full paths / short paths
Weird, that actually returned a string, unlike all my efforts, but it was the same string I put in.
|
|
07-05-2006 05:28 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Full paths / short paths
quote: Originally posted by alexp2_ad
Weird, that actually returned a string, unlike all my efforts, but it was the same string I put in.
Did you use GetFullPathNameW or GetFullPathNameA?
|
|
07-05-2006 05:31 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
Joined: May 2004
Status: Away
|
O.P. RE: [Help] Full paths / short paths
Used GetFullPathNameW as you said. Just tried GetFullPathNameA and it returned a bunch of chinese characters.
|
|
07-05-2006 05:34 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Full paths / short paths
quote: Originally posted by alexp2_ad
Used GetFullPathNameW as you said. Just tried GetFullPathNameA and it returned a bunch of chinese characters.
Ya because Javascript uses WChars so any API that has the ability of using Ascii or WChars you need to use the WChar so it is processed properly.
quote: Originally posted by Matty
quote: Originally posted by alexp2_ad
Weird, that actually returned a string, unlike all my efforts, but it was the same string I put in.
You might now have created your databloc properly to hold the amount of data.
This post was edited on 07-05-2006 at 05:40 PM by matty.
|
|
07-05-2006 05:39 PM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: [Help] Full paths / short paths
wrong function matty
code: function ConvertPath(sString){
var MAX_PATH = 260;
var sBuffer = Interop.Allocate(2*(MAX_PATH)+2);
Interop.Call('kernel32', 'GetLongPathNameW', sString, sBuffer, MAX_PATH);
return sBuffer.ReadString(0);
}
|
|
07-05-2006 05:42 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
Joined: May 2004
Status: Away
|
O.P. RE: [Help] Full paths / short paths
Yay, working!
Thanks both of you.
|
|
07-05-2006 05:45 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|