[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Calling function pointers

Robert

9/3/2010 5:04:00 PM

Hello all,

I was looking at the Dynamic Array functions exported by commctl32.dll
(prefixed DPA_ and DSA_)

http://msdn.microsoft.com/en-us/library/ff485930%28VS....

Although there doesn't seem to be anything there that really couldn't
be achieved in VB, I was still slightly disappointed that some of the
more interesting functions (DPA_Merge for example) are exported by
ordinal only.

I'm assuming that this means those ones aren't callable from straight
VB.

Robert
9 Answers

F*CK

9/3/2010 5:25:00 PM

0

As far as I know, we can call API using ordinal number.

Example:
Private Declare Function IsUserAnAdmin Lib "shell32" () As Long

would be

Private Declare Function IsUserAnAdmin Lib "shell32" Alias "#680" () As Long

Source: vbnet.mvps.org


"Robert" <noname@noserver.com> wrote in message
news:rq7286hjfoc5iobslpgt5u10f8sghmigu4@4ax.com...
| Hello all,


Karl E. Peterson

9/3/2010 7:05:00 PM

0

Robert presented the following explanation :
> exported by ordinal only.
>
> I'm assuming that this means those ones aren't callable from straight
> VB.

That's, in no way, a disqualifier on their use! Examples:

Private Declare Function SetWindowSubclass Lib "comctl32" Alias
"#410" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal
uIdSubclass As Long, ByVal dwRefData As Long) As Long

Private Declare Function GetWindowSubclass Lib "comctl32" Alias
"#411" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal
uIdSubclass As Long, pdwRefData As Long) As Long

Private Declare Function RemoveWindowSubclass Lib "comctl32" Alias
"#412" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal
uIdSubclass As Long) As Long

Private Declare Function DefSubclassProc Lib "comctl32" Alias "#413"
(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

While those functions are exported by name from XP onward, you can use
them with total success in any system that has v4.71+ of comctl32
(Win98 and/or IE 4.01) if you declare they by ordinal as above.

--
..NET: It's About Trust!
http://vfre...


dpb

9/3/2010 7:23:00 PM

0

Robert wrote:
....

Nomenclature nit...

DLL entry points identified by ordinal number are not "function pointers"...

--

Robert

9/3/2010 8:29:00 PM

0

On Fri, 3 Sep 2010 22:54:33 +0530, "Abhishek" <user@server.com> wrote:

>As far as I know, we can call API using ordinal number.
>

I really wasn't expecting that answer.

Thanks.

Now to decide if they are worth using for the custom control I'm
writing, rather than the dynamic array class I wrote myself.

Robert

9/3/2010 8:29:00 PM

0

On Fri, 03 Sep 2010 12:05:24 -0700, Karl E. Peterson <karl@exmvps.org>
wrote:

>While those functions are exported by name from XP onward, you can use
>them with total success in any system that has v4.71+ of comctl32
>(Win98 and/or IE 4.01) if you declare they by ordinal as above.

Thanks, Karl.

Robert

9/3/2010 8:29:00 PM

0

On Fri, 03 Sep 2010 14:22:34 -0500, dpb <none@non.net> wrote:

>Robert wrote:
>...
>
>Nomenclature nit...
>
>DLL entry points identified by ordinal number are not "function pointers"...

Yes, sorry about that.

I was thrown by the MSDN documentation for these functions which
states:

..... "is not exported by name or declared in a public header file. To
use it, you must use GetProcAddress and request ordinal 11 from
ComCtl32.dll to obtain a function pointer."

dpb

9/3/2010 9:11:00 PM

0

Robert wrote:
> On Fri, 03 Sep 2010 14:22:34 -0500, dpb <none@non.net> wrote:
>
>> Robert wrote:
>> ...
>>
>> Nomenclature nit...
>>
>> DLL entry points identified by ordinal number are not "function pointers"...
>
> Yes, sorry about that.
>
> I was thrown by the MSDN documentation for these functions which
> states:
>
> .... "is not exported by name or declared in a public header file. To
> use it, you must use GetProcAddress and request ordinal 11 from
> ComCtl32.dll to obtain a function pointer."
....

Yes, GetProcAddress returns the ordinal entry number as a C-style
function pointer. Remember MSDN API documentation is written for C.

--

ralph

9/3/2010 9:45:00 PM

0

On Fri, 03 Sep 2010 21:29:25 +0100, Robert <noname@noserver.com>
wrote:

>On Fri, 03 Sep 2010 14:22:34 -0500, dpb <none@non.net> wrote:
>
>>Robert wrote:
>>...
>>
>>Nomenclature nit...
>>
>>DLL entry points identified by ordinal number are not "function pointers"...
>
>Yes, sorry about that.
>
>I was thrown by the MSDN documentation for these functions which
>states:
>
>.... "is not exported by name or declared in a public header file. To
>use it, you must use GetProcAddress and request ordinal 11 from
>ComCtl32.dll to obtain a function pointer."

Yeah, you will see the term "pointer" a lot when people actually mean
a "Address", especially when describing System services, etc. since
most 'system' programmers are C programmers.

To be really picky - the term "pointer" shouldn't be used any time
outside the scope of a language that actually supports a 'pointer data
type' (especially never in VB or Java) - they should always use the
more correct term "address".

But such a admonishment will only start a fight. <bg>

-ralph

(nobody)

9/3/2010 10:12:00 PM

0

Why spend the time in reinventing the wheel, when API based coomon controls
are available?

Download the following VB source library which implement all the common
controls as classes, with many properties and methods. No need to
redistrubute any OCX. The only catch is that
anything created with CreateWindowEx doesn't fire Validate event in other
controls, nor navigation keys such as tab will work, because VB doesn't know
the API created window is there. The solution to this involves turning the
class into UserControl, and implementing IOLEInPlaceActiveObject hack, so VB
can "see" the control. Search the web for "vb IOLEInPlaceActiveObject" for
more details.

http://sourceforge.net/project...