moridin Posted April 10, 2007 Posted April 10, 2007 Hi, I am fairly new to autoit, and I want to use a dll function in one of my scripts. I am an experienced vb6 (Visual Basic) user, and i am trying to find out how to translate a vb6 function to autoit. This is the vb6 function declaration; Private Declare Function Desktop_Show_Hide Lib "dllname.dll" (ByVal bShowHide As Boolean) As Integer And it is called by; Desktop_Show_Hide (boolean value) I cannot seem to make this work using the autoit dllcall function. I was wondering if someone could give me an exact code example? This is the sort of thing I have tried so far; $dll = DllOpen("dllname.dll") $result = DllCall($dll,"none","Desktop_Show_Hide","BOOL","FALSE") DllClose($dll) The dll is written in c++, here is the code for this particular function; expandcollapse popupint DLL_EXP_IMP WINAPI Desktop_Show_Hide(BOOL bShowHide) { OSVERSIONINFO osvi; BOOL bIsWindowsNT4SP3orLater; int iServicePack; char *p; // Determine the current windows version osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); for (p = osvi.szCSDVersion; *p && !isdigit(*p); *p++); iServicePack = atoi(p); bIsWindowsNT4SP3orLater = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (((osvi.dwMajorVersion == 4) && (iServicePack >= 3)) || (osvi.dwMajorVersion > 4)); if (!bShowHide) { if (!hHook) { hHook = SetWindowsHookEx(bIsWindowsNT4SP3orLater ? WH_MOUSE_LL : WH_MOUSE, bIsWindowsNT4SP3orLater ? (HOOKPROC)LowLevelMouseHookProc : (HOOKPROC)MouseHookProc, hInst, 0); if (!hHook) return 0; } } else { UnhookWindowsHookEx(hHook); hHook = NULL; } return SetWindowPos(FindWindow(NULL, PROGRAM_MANAGER), NULL, 0, 0, 0, 0, bShowHide ? SWP_SHOWWINDOW : SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER); } Note: I know that this may seem to be malicious code to some, as it will hide the desktop, but I am making a "kiosk" style app designed to restrict users from running programs they are not authorized to, while allowing the to do what the need in a very restricted environment without me having to mess about with group policy. I also have within this dll functions to disable ctrl+alt+del (yes, it can be done!) and task manager etc. If anybody would like to know how to do this I can link you to the site where I found it. But please do not be discouraged from answering me because this may seem like malicious coding. Help would be much appreciated. -Moridin
BrettF Posted April 10, 2007 Posted April 10, 2007 Welcome to the forum! I would also like to see the result of this, as I too am in the process of making a kiosk program. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
moridin Posted April 10, 2007 Author Posted April 10, 2007 Thank you. I have only had one post, but I've been trying to ask this question for quite a while. The forum just does not seem to like me. :"> Would you like to know all the functions in the dll?
zatorg Posted April 10, 2007 Posted April 10, 2007 $dll = DllOpen("dllname.dll") $result = DllCall($dll,"none","Desktop_Show_Hide","BOOL","FALSE") DllClose($dll)Hello, the code should be: $dll = DllOpen( "dllname.dll" ) $result = DllCall( $dll, "int", "Desktop_Show_Hide", "int", 0 ) DllClose( $dll ) $result[ 0 ] then holds the return value. You want to check whether @error is set to something but zero too...
moridin Posted April 10, 2007 Author Posted April 10, 2007 Thank you so much, that works perfectly!!! I have been trying to figure this out for ages. And I wasn't too far off....Anyway, for those of you (i.e. Bert) who would like to know how to implement these features into your autoit scripts, here is a list of the functions in the DLL, and how to use them with autoit;Use 0 as the last parameter to hide/disable, 1 to unhide/re-enable.WARNING, if you are stupid, you could screw up your computer. Well at least to the point of a reboot, so be CAREFUL! I take no responsibilty for anything.Hide DesktopDllCall("WinLockDLL.dll", "int", "Desktop_Show_Hide", "int", 0)oÝ÷ Øxy+Z®Ðn¶Ú'jëh×6DllCall("WinLockDLL.dll", "int", "StartButton_Show_Hide", "int", 0)oÝ÷ Øxy6¬¶«jëh×6DllCall("WinLockDLL.dll", "int", "Taskbar_Show_Hide", "int", 0)oÝ÷ Øxy,¬µé$jëh×6DllCall("WinLockDLL.dll", "int", "Clock_Show_Hide", "int", 0)oÝ÷ Ø8¬i¹^jYl¥ç"jYÊÊ',(®K"h§÷)äjëh×6DllCall("WinLockDLL.dll", "int", "Keys_Enable_Disable", "int", 0)oÝ÷ Ø8¬i¹^[~M¦ç¢×¢z-r§ëayø«²Ý" mM¦övàⱦå{}÷Ý«¢+Ù±± ±° ÅÕ½Ðí]¥¹1½10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí±ÑQÅ}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À¤)±± ±° ÅÕ½Ðí]¥¹1½10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí±ÑQÉ}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀoÝ÷ Ø8¬i¹^M«$Kr§§²±h§ì¾ §-¹©eÉ©òÂ)ä{/¬írëb¶§«¢+Ù±± ±° ÅÕ½Ðí]¥¹1½10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíQÍMݥѡ¥¹}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀoÝ÷ Ø8¬i¹^ Úåø mø7¥ Úåù(b~߱Ʈ¶sdFÆÄ6ÆÂgV÷CµväÆö6´DÄÂæFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C´7G&ÄÇDFVÅôVæ&ÆUôF6&ÆRgV÷C²ÂgV÷C¶çBgV÷C²ÂHere is the link to the VB6 and C++ Source code, exes and the DLL.WinLock by A. Miguel FeijaoSorry if this is inappropriate because of its possible maliciousness.-Moridin
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