General DllCall Information
Keywords: dllcall
Question:
- Is there a way to write our own dll's with winbatch? are they that difficult?
- I have heard that it is possible to use other dll's from say a "packaged" vendor like microsoft. How would I know what the dll does and what its functions, sytaxtical requirements, etc, ad nausium are? I would figure that "dllcall" function group would handle the passing of parameters to that dll. right?
Answer:
- No. Using MSC or other compilers you may be able to write Dlls that WinBatch can use, but you cannot make a DLL with WinBatch.
What are you hoping to do?
- Ah. That is the crux of the issue. You *need* the documentation on how to use the DLL. When people sell or give away DLLs for such use they will provide documentation on how to use the DLL. WinBatch can work with many standard "Windows API" type DLLs.
You can get documentation for the Windows DLLs fairly easily. Ummm the MS Website has a lot of the documentation required.
However it can be a tough task to get your first few DllCalls running, but after that it gets a *lot* easier.
Question:
I am not really looking to accomplish any thing more than incoporate more functionality into my programs. I thought I saw a mention of dll writing and whatnot in another discussion here. just thought I would ask. What are the stumbling blocks that you think are most notorius for keeping newbies dllcall's from working?Answer:
It kind of helps (but is not competely necessary) to have a C programming background when trying to work with the documentation available for most DLLS.When using DllCall to call DLLs special pains must be taken for and "output" type parameters in the calling parameters.
Different special pains must be taken for any API thts wants a "structure".
But basically you are in the correct place.
For Windows APIs See..
Functions in Alphabetical order:
http://msdn.microsoft.com/library/psdk/psdkref/alphafunc_3bjm.htmFunctions by category:http://msdn.microsoft.com/library/psdk/psdkref/catfunc_26m1.htmGet a few of them working to cut your teeth. Post code here for comments and help. Keep it simple. Drink lots of coffee.MAKE SURE YOUR MACHINE IS BACKED UP!
DllCall - IsCharAlphaNumericA
Question:
- I've decided to take the plunge into API calls. I'm getting my feet wet with simple calls like IsCharAlphaNumericA.
The code below doesn't generate any errors, but sometimes the SAME character being tested is true (1) and sometimes it's False (0)!
Is there some sort of caching going on? I'm I doing it wrong? What's going on?
I tried adding GetLastError but it always returns 0. Pretty sure I'm doing it wrong.
- Is there are reference chart (or at least a rule of thumb) that shows how the multitude of WinAPI data types map to the 4 or 5 Winbatch types?
******************************************* a0="@" dllname=strcat(dirwindows(1),"USER32.DLL") dllname2=strcat(dirwindows(1),"Kernel32.dll") a1=DllCall(dllname, word:"IsCharAlphaNumericA", lpstr:a0) error= DllCall(dllname2, long:"GetLastError") Message(a0,"Alpha/Num? = %a1%%@CRLF%Last Error = %error%")Answer:
>1)1)I've decided to take the >plunge into API calls. I'm >getting my feet wet with >simple calls like >IsCharAlphaNumericA.Not the simplest call. But not a bad choice.> >The code below doesn't >generate any errors, but >sometimes the SAME character >being tested is true (1) and >sometimes it's False (0)! > >Is there some sort of caching >going on? I'm I doing it >wrong? What's going on? > >I tried adding GetLastError >but it always returns 0. >Pretty sure I'm doing it >wrong. >Basically you were not checking what you though you were checking. A string pointer was being passed, and it checked the somewhat random value of the string pointer.>2) Is there are reference >chart (or at least a rule of >thumb) that shows how the >multitude of WinAPI data types >map to the 4 or 5 Winbatch >types?Revised version. Characters are not strings, the poor thing was getting confused.
- Numbers and handles are generally LONG.
- NULL is lpnull
- Strings are generally LPSTR
- Anything that tries to pass data back thru a variable has to be done via a binary buffer.
- Most anything can be forced to a long.
a0="B" a0x=strsub(a0,1,1) a0x=Char2Num(a0x) dllname=strcat(dirwindows(1),"USER32.DLL") dllname2=strcat(dirwindows(1),"Kernel32.dll") a1=DllCall(dllname, long:"IsCharAlphaNumericA", long:a0x) error= DllCall(dllname2, long:"GetLastError") Message(a0,"Alpha/Num? = %a1%%@CRLF%Last Error = %error%")
Article ID: W14839