Announcement

Collapse
No announcement yet.

Help Needed with DLLs and received output

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help Needed with DLLs and received output

    Hello
    I'm trying to convert a UTF-8 string to ANSI using the "Kernel32.dll" with it's "WideCharToMultiByte" function.
    The problem is that this specific function doesn't output the result and directly writes to a specified Variable. It only outputs a number for evaluation purposes.
    How can I pass a variable as a parameter and let that function fill it for me? The problem is that AMS resolves all variables before passing them to DLL. I can't think of any way to introduce the variable directly to DLL and let it work with it!
    The detailed info from MSDN is given as a link.

    Mycode:
    Code:
    local CodePage = 1256 ;
    local dwFlags = 0 ;
    local cchWideChar = String.Length(U);
    local cbMultiByte = DLL.CallFunction(_SystemFolder .. "\\kernel32.dll", "WideCharToMultiByte", CodePage .. "," .. dwFlags .. "," .. U .. "," .. cchWideChar .. "," .. S .. ",0,0,0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    local lpDefaultChar = 0;
    local lpUsedDefaultChar = 0;
    local S = "" ;
    Result = DLL.CallFunction(_SystemFolder .. "\\kernel32.dll", "WideCharToMultiByte", CodePage .. "," .. dwFlags .. "," .. U .. "," .. cchWideChar .. "," .. S .. "," .. cbMultiByte .. "," .. lpDefaultChar .. "," .. lpUsedDefaultChar, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    Also tried this to no avail :
    Code:
    local CodePage = 1256 ;
    local dwFlags = 0 ;
    local cchWideChar = String.Length(U);
    local cbMultiByte = DLL.CallFunction(_SystemFolder .. "\\kernel32.dll", "WideCharToMultiByte", CodePage .. "," .. dwFlags .. "," .. U .. "," .. cchWideChar .. "," .. S .. ",0,0,0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    local lpDefaultChar = 0;
    local lpUsedDefaultChar = 0;
    local S = "" ;
    Result = DLL.CallFunction(_SystemFolder .. "\\kernel32.dll", "WideCharToMultiByte", string.format("%s,%s,%s,%s,%s,%s,%s,%s", CodePage, dwFlags, U, cchWideChar, S, cbMultiByte, lpDefaultChar, lpUsedDefaultChar), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    Thank you in advance!

    excerpt from MSDN: Return value

    Returns the number of bytes written to the buffer pointed to by lpMultiByteStr if successful. If the function succeeds and cbMultiByte is 0, the return value is the required size, in bytes, for the buffer indicated by lpMultiByteStr. If the input byte/char sequences are invalid, returns U+FFFD for UTF encodings.
    The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError,
Working...
X