April 19, 2024, 10:02:15 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


PathCompactPath

Started by Brian, March 15, 2018, 01:19:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,

Can anyone help me with some sample code of PathCompactPath, or PathCompactPathEx?

I'm struggling here! And also what to $include or $use, etc

Thanks a lot,

Brian

fasecero

March 15, 2018, 05:46:13 PM #1 Last Edit: March 15, 2018, 05:52:01 PM by fasecero
I've never heard of this function before but I think it can be handy! Here's a small sample



$INCLUDE "windowssdk.inc"
$INCLUDE "Shlwapi.inc"

OPENCONSOLE
PRINT "Starting..."
PRINT ""

DoSomething()

PRINT ""
PRINT "Press any key to exit"
DO:UNTIL INKEY$ <> ""
CLOSECONSOLE

END

SUB DoSomething()
string path = ""

HWND myconsole = GetConsoleWindow()

IF myconsole THEN
HDC mydc = GetDC(myconsole)

IF mydc THEN
path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 125)
print path

path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 70)
print path

path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 30)
print path

ReleaseDC(myconsole, mydc)
ENDIF
ENDIF
ENDSUB

Brian

Thanks, Fasecero,

I reckon I was over-thinking it - you have made it look so easy

Brian