in reply to Win32::API : Creating a LPCWSTR type input parameter from a string

Get rid of

$profileName = pack ('p', $profileName);

Win32::API recognises LPCWSTR and should handle it properly.

I could see it passing "t" instead of "test", though. The prototype interface is... troublesome. If that's the case, I'd avoid the prototype interface, define strProfileName as an "N", and pass unpack('J', pack('p', $profileName)).

Replies are listed 'Best First'.
Re^2: Win32::API : Creating a LPCWSTR type input parameter from a string
by ajose (Acolyte) on Aug 24, 2011 at 10:06 UTC

    Thanks for the reply. Did you mean API declaration as the prototype interface?. If not, I have included the parameter declaration which is used in my script. I believe 't' is being passed since I used "encode("UTF-16LE", $profileName)" in the code. So I removed that also.

    Following is the code snippet after making the above changes. Error message is also mentioned below:

    ['WlanGetProfile' => 'IPNIPPI' => 'I'], $profileName = unpack('J', pack('p', $profileName)); $API{ api}->Call($handle, $interface, $profileName, 0, $profileXml, 0, + 0));
    An attempt was made to reference a token that does not exist at .....