http://www.perlmonks.org?node_id=921950

ajose has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am just beginner in using the Perl module Win32::API. I could successfully invoke the Win32 API's and parse the return values using this module. But now I am stuck at a point where I have to invoke the API with a parameter of data type LPCWSTR as an input parameter. I tried following method to achieve the same.

$profileName = encode("UTF-16LE", $profileName); $profileName = pack ('p', $profileName); $API{ api}->Call($handle, $interface, $profileName, 0, $profileXml +, 0, 0));

API declaration:

DWORD WINAPI WlanGetProfile( __in HANDLE hClientHandle, __in const GUID *pInterfaceGuid, __in LPCWSTR strProfileName, __reserved PVOID pReserved, __out LPWSTR *pstrProfileXml, __inout_opt DWORD *pdwFlags, __out_opt PDWORD pdwGrantedAccess );

Output is:

Argument "t\0e\0s\0t\0\0\0\0\0\0\0\0\0\0\0\0\0..." isn't numeric in su +broutine entry at ...

Please help me by suggesting any work around to convert the string to LPCWSTR format before invoking the API. Also output of this API call is also a pointer type(LPWSTR). Hence please help me here also.