|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calling function pointersHello 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.85%29.aspx 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 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 Show quoteHide quote "Robert" <non***@noserver.com> wrote in message news:rq7286hjfoc5iobslpgt5u10f8sghmigu4@4ax.com... | Hello all, On Fri, 3 Sep 2010 22:54:33 +0530, "Abhishek" <u***@server.com> wrote: I really wasn't expecting that answer.>As far as I know, we can call API using ordinal number. > 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 presented the following explanation :
> exported by ordinal only. That's, in no way, a disqualifier on their use! Examples:> > I'm assuming that this means those ones aren't callable from straight > VB. 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. On Fri, 03 Sep 2010 12:05:24 -0700, Karl E. Peterson <k***@exmvps.org>
wrote: >While those functions are exported by name from XP onward, you can use Thanks, Karl.>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. Robert wrote:
.... Nomenclature nit... DLL entry points identified by ordinal number are not "function pointers"... -- On Fri, 03 Sep 2010 14:22:34 -0500, dpb <n***@non.net> wrote:
>Robert wrote: Yes, sorry about that.>... > >Nomenclature nit... > >DLL entry points identified by ordinal number are not "function pointers"... 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." Robert wrote:
Show quoteHide quote > On Fri, 03 Sep 2010 14:22:34 -0500, dpb <n***@non.net> wrote: Yes, GetProcAddress returns the ordinal entry number as a C-style > >> 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." .... function pointer. Remember MSDN API documentation is written for C. -- On Fri, 03 Sep 2010 21:29:25 +0100, Robert <non***@noserver.com>
wrote: Show quoteHide quote >On Fri, 03 Sep 2010 14:22:34 -0500, dpb <n***@non.net> wrote: Yeah, you will see the term "pointer" a lot when people actually mean> >>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." 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 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/projects/codebox/
What Is the User Path for Deployment Similar to $(AppPath)?
Looking for VC6 newsgroup Error 481 Invalid picture Global class and WithEvents Distibution of VB6 program Closing Grouped instances in the taskbar Componenet not installed correctly by PDW Error 5: ERROR_ACCESS_DENIED when accessing registry in Windows 7 Call for votes: New german discussion group for VB.classic in de.* CopyFile method not working |
|||||||||||||||||||||||