AutoHotkey Community

It is currently May 27th, 2012, 12:31 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Function help
PostPosted: December 14th, 2009, 7:50 am 
Offline

Joined: September 15th, 2006, 10:25 am
Posts: 567
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2009, 10:56 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks a lot!!
PostPosted: December 14th, 2009, 4:47 pm 
Offline

Joined: September 15th, 2006, 10:25 am
Posts: 567
Thanks a lot!! It works just fine..
I will soon post a thread with controls for my TVR, so that someone else may benefit..


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, iDrug, Leef_me, Ohnitiel, rjgatito, Yahoo [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group