AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function help

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
shajul



Joined: 15 Sep 2006
Posts: 564

PostPosted: Mon Dec 14, 2009 6:50 am    Post subject: Function help Reply with quote

Please help me convert this function to AHK.. I have no programming experience.

'int (__stdcall *VendorCmdRW.dll!GetIRCode)(unsigned char*)'

I believe I don't have to mention about the InitIR API. But that was pretty simple; the prototype turned out to be
'void (__stdcall *InitIR)(void)'

This is from the thread control applications with TV-tuner's remote control
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Mon Dec 14, 2009 9:56 am    Post subject: Reply with quote

I presume "VendorCmdRW.dll!" means it is in that file. I'd be surprised if that is valid C/C++. Anyway,
Code:
int (__stdcall *VendorCmdRW.dll!GetIRCode)(unsigned char*)
  • int - This is the default return type for DllCall, so we don't need to specify a return type.
  • ( * ) - It appears to be defining a pointer to a function rather than the actual exported function. If we assume the signature is correct, we can ignore this part.
  • __stdcall - This is the default calling convention for DllCall, so we can ignore it.
  • unsigned char* - This part might be straightforward (see below). C/C++ char is equivalent to DllCall's Char. Since it is unsigned, we prepend U. * means it is a pointer; for DllCall we just append * or P: "UChar*" or UCharP.
Try this:
Code:
r := DllCall("VendorCmdRW.dll\GetIRCode", UCharP, ir_code)
MsgBox % "return: " r ", output: " ir_code

However, occasionally in C/C++ a pointer type is used not as a pointer to a single value, but a pointer to an array of arbitrary length. UCharP only covers the former case; in the latter case, the code above may be unsafe. We would need to know the usage of the function, not just its signature.
Back to top
View user's profile Send private message Visit poster's website
shajul



Joined: 15 Sep 2006
Posts: 564

PostPosted: Mon Dec 14, 2009 3:47 pm    Post subject: Thanks a lot!! Reply with quote

Thanks a lot!! It works just fine..
I will soon post a thread with controls for my TVR, so that someone else may benefit..
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group