Shoutbox

[Help] Full paths / short paths - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] Full paths / short paths (/showthread.php?tid=62597)

[Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 04:55 PM

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?


RE: [Help] Full paths / short paths by matty on 07-05-2006 at 05:10 PM

you will want to use GetFullPathNameW api if i remember correctly


RE: RE: [Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 05:13 PM

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. :)
RE: [Help] Full paths / short paths by matty on 07-05-2006 at 05:22 PM

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);
}

RE: [Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 05:28 PM

Weird, that actually returned a string, unlike all my efforts, but it was the same string I put in.


RE: [Help] Full paths / short paths by matty on 07-05-2006 at 05:31 PM

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?
RE: [Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 05:34 PM

Used GetFullPathNameW as you said.  Just tried GetFullPathNameA and it returned a bunch of chinese characters. :S


RE: [Help] Full paths / short paths by matty on 07-05-2006 at 05:39 PM

quote:
Originally posted by alexp2_ad
Used GetFullPathNameW as you said.  Just tried GetFullPathNameA and it returned a bunch of chinese characters. :S
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.

RE: [Help] Full paths / short paths by Eljay on 07-05-2006 at 05:42 PM

wrong function matty :P

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);
}

RE: [Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 05:45 PM

Yay, working! :)

Thanks both of you. (y)


RE: [Help] Full paths / short paths by matty on 07-05-2006 at 05:45 PM

quote:
Originally posted by Eljay
wrong function matty :P

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);
}

How he said it worked?
RE: RE: [Help] Full paths / short paths by alexp2_ad on 07-05-2006 at 05:46 PM

quote:
Originally posted by Matty
How he said it worked?

No, I said it returned the same thing I put in. :S

GetLongPathNameW works.  Thanks for the help. :)