Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I get short path name in VFP?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How can I get short path name in VFP?
Divers
Thread ID:
00711861
Message ID:
00711861
Vues:
119
Hi, Everyone,

Please help. I am using an Image Printer which only takes short file path and name, so I must convert the long file name that I use in VFP. So I found GetShortPathName in WIN32API. But I get very unpredictable results: sometimes the function succeds while other times fail with the exactly the same parameters that I pass to the function. The following is the function that atempts to achieve this goal:
LPARAMETERS lpcdir
IF VARTYPE(m.lpcdir)#"C" OR EMPTY(lpcdir) THEN 
	RETURN [] 
ENDIF 
DECLARE integer GetShortPathName IN WIN32API AS API_GetShortPathName String,String@,integer  
LOCAL lcLongPath, lcShortPath, lnReturn
m.lnReturn = 0 
lcShortPath = SPACE(127)+CHR(0)
m.lcLongPath = ALLTRIM(m.lpcDir) + CHR(0) 
m.lnReturn = API_GetShortPathName(lcLongPath,@lcShortPath,128)
IF m.lnReturn >0 THEN 
	m.lcShortPath = ALLTRIM(m.lcShortPath) 
	IF LEN(m.lcShortPath)>0 THEN 
		m.lpcDir = LEFT(m.lcShortPath, LEN(m.lcShortPath)-1) 
	ENDIF 
ENDIF 
RETURN lpcdir
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform