argv rtl_getAppCommandArg [solved]

I’m very sorry, but I don’t understand, trying to write app for LibreOffice made using SDK.

Im trying to get argv from main command arguments
I send string in command argument “file:///C:\Users\USER\CProjects\test\test2.docx”

And by the examples i have to get path arg sAbsoluteDocUrl with commands:

	OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl, sArgDocUrl;
	rtl_getAppCommandArg(0, &sArgDocUrl.pData);

	osl_getProcessWorkingDir(&sWorkingDir.pData);
	osl::FileBase::getFileURLFromSystemPath(sArgDocUrl, sDocPathUrl);
	osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);

and then make
Reference< XComponent > xMainComponent = xDesktop2->loadComponentFromURL(
sAbsoluteDocUrl, OUString("_blank"),
0, loadProps);

but sAbsoluteDocUrl don’t have url finally

but if i put

	rtl::OUString path = "file:///C:\\Users\\USER\\CProjects\\test\\test2.docx";

and then run

	Reference< XComponent > xMainComponent = xDesktop2->loadComponentFromURL(
		path , OUString("_blank"),
		0, loadProps);

the document would run succesfully.

How to get args correctly?
Is it realy nessesary run something like

	-env:URE_MORE_TYPES=\"file:///.../program/offapi.rdb\" \"file:///e:/temp/test.odt\" 		\"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n"

as it described in DocumentLoader.cxx
https://api.libreoffice.org/examples/examples.html#Cpp_examples

Note that using \ is illegal in URIs…

I tried a lot of variants and using // not helped

but sAbsoluteDocUrl don’t have url finally

So what does it contain then?

And sArgDocUrl actually contains the argument passed?

getFileURLFromSystemPath doesn’t work with URIs, it accepts system path only - i.e., it may take C:\path\file, but not file://C:/path/file. Do you check the result? You likely need to have a fallback to simply pass the initial string to the loadComponentFromURL in case getFileURLFromSystemPath failed because of invalid argument

printf argv[1]=C://path//to//file
printf sAbsoluteDocUrl returns smile
printf sAbsoluteDocUrl.pData returns smile
cout sAbsoluteDocUrl.pData returns 1000007FECCDCBCC8

caught UNO exception: Unsupported URL <>:from LoadEnv::initializeLoading

C://path/to/file - similar

C:/path/to/file - done!!! thanks!!!

printf argv[1]=C://path//to//file

printf sAbsoluteDocUrl returns smile

printf sAbsoluteDocUrl.pData returns smile

cout sAbsoluteDocUrl.pData returns 1000007FECCDCBCC8

caught UNO exception: Unsupported URL <>:from LoadEnv::initializeLoading

C://path/to/file - similar

C:/path/to/file - done!!! thanks!!!