Iczer Posted February 21, 2017 Share Posted February 21, 2017 I have some troubles understanding data types of returned by my freebasic dll values : Function Time_GetCurrentISOWeekNumber_Orig() should return String value (two digits), but actually return "ђЖ¤" Function Time_GetCurrentISOWeekNumber() is working as intended Why STR value not recognized by Autoit or, it seems, have first bytes of string replaced by something (maybe BOM?) Freebasic dll code: Spoiler #include once "vbcompat.bi" #include once "string.bi" '========================================================================================== Extern "Windows-MS" '========================================================================================== Public Function Time_GetCurrentISOWeekNumber() As wString Ptr Export Dim As Double d = Now() Dim As String * 8 WeekISO = Format(DatePart("ww", d, fbMonday, fbFirstFourDays),"00") Return WinAPI_MultiByteToWideChar(65001, StrPtr(WeekISO)) End Function '========================================================================================== Public Function Time_GetCurrentISOWeekNumber_Orig() As String Export Dim As Double d = Now() Dim As String * 8 WeekISO = Format(DatePart("ww", d, fbMonday, fbFirstFourDays),"00") Return WeekISO End Function '========================================================================================== End Extern '========================================================================================== Autoit code: Spoiler #include <Date.au3> Global $hDLL = DllOpen($sPathTocDLL) ConsoleWrite(Time_GetCurrentISOWeekNumber() & @CRLF) ConsoleWrite(Time_GetCurrentISOWeekNumber_Orig() & @CRLF) ConsoleWrite(_WeekNumberISO () & @CRLF) ;============================================================================================================================================================================================== Func Time_GetCurrentISOWeekNumber() Local $aRet = DllCall($hDLL,"WSTR*","Time_GetCurrentISOWeekNumber") If @error Then Return SetError(1000 + @error, 1000 + @extended,False) Return $aRet[0] EndFunc ;============================================================================================================================================================================================== Func Time_GetCurrentISOWeekNumber_Orig() Local $aRet = DllCall($hDLL,"STR","Time_GetCurrentISOWeekNumber_Orig") If @error Then Return SetError(1000 + @error, 1000 + @extended,False) Return $aRet[0] EndFunc ;============================================================================================================================================================================================== Link to comment Share on other sites More sharing options...
JohnOne Posted February 21, 2017 Share Posted February 21, 2017 Try Local $aRet = DllCall($hDLL,"WSTR","Time_GetCurrentISOWeekNumber_Orig"); WSTR AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Iczer Posted February 21, 2017 Author Share Posted February 21, 2017 In this case return value is "?¤" Link to comment Share on other sites More sharing options...
Iczer Posted February 23, 2017 Author Share Posted February 23, 2017 No one? here dll (x64) for any one interested Time_GetCurrentISOWeekNumber.dll Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2017 Share Posted February 23, 2017 I think that dlls that return strings do not play nice with autoit and probably any other language. You will notice windows api functions mostly require caller to pass it a buffer to fill if you want a string from it. I believe that is the crux of you issue. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Danyfirex Posted February 27, 2017 Share Posted February 27, 2017 Hello. Try this. Func Time_GetCurrentISOWeekNumber_Orig() Local $aRet = DllCall($hDLL, "ptr", "Time_GetCurrentISOWeekNumber_Orig") If @error Then Return SetError(1000 + @error, 1000 + @extended, False) Return DllStructGetData(DllStructCreate("char[2]", DllStructGetData(DllStructCreate("ptr", $aRet[0]), 1)), 1) EndFunc ;==>Time_GetCurrentISOWeekNumber_Orig Saludos Iczer and jguinch 2 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
jguinch Posted February 27, 2017 Share Posted February 27, 2017 I really think Danyfirex has some magical powers... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Iczer Posted February 27, 2017 Author Share Posted February 27, 2017 Wow! Thanks! Simple string in freebasic not as simple as it sound it seems. Link to comment Share on other sites More sharing options...
Danyfirex Posted February 27, 2017 Share Posted February 27, 2017 8 hours ago, jguinch said: I really think Danyfirex has some magical powers... Yes I have but not sure if it's magical. I destroy everything I touch (This is my gift, My curse) lol 27 minutes ago, Iczer said: Wow! Thanks! Simple string in freebasic not as simple as it sound it seems. It it not so hard. the unicode version you return a Pointer to string (wString Ptr Export) for that you can use wstr as return in the dllcall. The other one you return a string only for that you get a pointer to a pointer that points to a string lol. that's how I see it. maybe if you use something like String Ptr Export it works. I'm not sure because I dont know freebasic. But it should be something like that I think. Saludos jvanegmond 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now