Hello Kyo,
according to Microsoft documentation, the selected file name is stored as zero terminated string in the data field lpstrFile in the OPENFILENAME data structured passed to the Win32 function GetOpenFileName(). To relay this string to Embedded Wizard application use the function EwNewStringAnsi() or EwNewString(). These function will take care of the proper memory management for the new string. Whether you use the first or second function depends on the version of the GetOpenFileName() function. Win32 provides in this case the functions for ANSI or WCHAR strings (identifier by a final A or W sign in the name according to Microsoft).
Following could be the code to obtain an Embedded Wizard conform string from the ANSI version of the GetOpenFileName() function:
var string fileName = "";
native ( fileName )
{
OPENFILENAMEA data;
/* Initialize the data structure ... */
data.lStructSize = sizeof( data );
[...]
if ( GetOpenFileNameA( &data ))
fileName = EwNewStringAnsi( data.lpstrFile );
}
// Again in Embedded Wizard world -> use the name returned by Windows.
trace "User has selected the file:", fileName;
I hope it helps you further. See also: Be careful when exchanging strings.
Best regards
Paul Banach