What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help] Full paths / short paths

Pages: (2): « First [ 1 ] 2 » Last »
[Help] Full paths / short paths
Author: Message:
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
Joined: May 2004
Status: Away
O.P. Huh?  [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
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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
Profile E-Mail PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
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
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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
Profile E-Mail PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
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
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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
Profile E-Mail PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
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. :S
07-05-2006 05:34 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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. :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.

This post was edited on 07-05-2006 at 05:40 PM by matty.
07-05-2006 05:39 PM
Profile E-Mail PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [Help] Full paths / short paths
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);
}
07-05-2006 05:42 PM
Profile PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
Joined: May 2004
Status: Away
O.P. RE: [Help] Full paths / short paths
Yay, working! :)

Thanks both of you. (y)
07-05-2006 05:45 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On