Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing file path to old win9x app

Status
Not open for further replies.

john0532

Programmer
Jul 2, 2002
27
0
0
US
I'm trying to send the file path
c:\documents and settings\<username>\my documents\<filename>
to an old COTS application that will not accept blanks in the path. Does anybody have any ideas on how this could be done? The DOCUMENTS AND SETTINGS portion can be changed to DOCUME~1 but what can I do with the MY DOCUMENTS portion?

Thanks
 
I tried GetShortPathName() and got an error 123 which means

The filename, directory name, or volume label syntax is incorrect.

It looks like there is no way around the space in the file path being unacceptable.
 
Did you cout the path you passed to GetShortFileName()? What does it look like?
 
the path is:
c:\documents and settings\jms0532\my documents\O2548


 
Can you post the code you're using when you call that function?
 
the path is generated and saved in a CString several hundred lines previous to where i call GetShortPathName(). It would take a major effort to dig it out. I think I'm just going to copy the file to C:\TEMP and pass the old app that path.

Dou you think GetShortPathName() can handle a blank in the path name? I know DOCUMENTS AND SETTINGS is converted to DOCUME~1 (truncates the spaces) but I don' think it can handle the space in MY DOCUMENTS.
 
Code:
#include <windows.h>
#include <iostream>

using namespace std;


int main()
{
	char longpath[] = "C:\\Documents and Settings\\Default User\\Application Data\\Microsoft";
	char shortpath[ 255 ];

	GetShortPathName( longpath, shortpath, 255 );
	cout << endl << "Long Path:  " << longpath
		 << endl << "Short Path: " << shortpath << endl;

	return 0;
}
The output is:

Long Path: C:\Documents and Settings\Default User\Application Data\Microsoft
Short Path: C:\DOCUME~1\DEFAUL~1\APPLIC~1\MICROS~1
 
My Documents would be truncated to something like MYDOCU~1 - say DIR to Win98 DOS prompt. You probably are trying to find a short name of not existing yet file. I suppose, it should be impossible, because short names are generated authomatically during the file creation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top