Can anyone make this work in Delphi ??
This Extract from
PCPLUS magazine May 2000 Dave Jewel, C++ Workshop 'How to make undocumented API calls'
Use of GetProcAddress
Unfortunately the import libraries supplied with C++ (or Delphi sgg) don't contain entries for the undocumented API calls and that's why we need to make use of GetProcAddress, enabling us to track down the unwanted routine for ourselves. As you will probably realise, most of the routines exported from a DLL are exported by name, in other words you only need the name of the target routine to in order to retrieve its address using getprocaddress. However Microsoft was a little sneaky when it came to implementing the undocumented API routines, rather than exporting these routine by name, they are exported by ordinal, in other words by number.
Most of the time when you see other programmers using getprocaddress they will pass a routine by name as the second parameter. This won't work for us because the routines we want are only accessible by number.
But how to pass a number to a routine that expects a string,? This is when we use another classic programmers trick in the shape of MAKEINTRESOURCE macro This enable us to take the number (62 in the case of PickIconDlg) and transmogrify it into a form which the C++ compiler will accept as a number.
You will also notice that the routine address returned from GetProcAddress has to be cast into to the procedural type that we want to work with - in this case PICKICONDLGPROC If we don't do this the compiler will complain that it cannot convert from one procedural type to another.
Steve.
This Extract from
PCPLUS magazine May 2000 Dave Jewel, C++ Workshop 'How to make undocumented API calls'
Use of GetProcAddress
Unfortunately the import libraries supplied with C++ (or Delphi sgg) don't contain entries for the undocumented API calls and that's why we need to make use of GetProcAddress, enabling us to track down the unwanted routine for ourselves. As you will probably realise, most of the routines exported from a DLL are exported by name, in other words you only need the name of the target routine to in order to retrieve its address using getprocaddress. However Microsoft was a little sneaky when it came to implementing the undocumented API routines, rather than exporting these routine by name, they are exported by ordinal, in other words by number.
Most of the time when you see other programmers using getprocaddress they will pass a routine by name as the second parameter. This won't work for us because the routines we want are only accessible by number.
But how to pass a number to a routine that expects a string,? This is when we use another classic programmers trick in the shape of MAKEINTRESOURCE macro This enable us to take the number (62 in the case of PickIconDlg) and transmogrify it into a form which the C++ compiler will accept as a number.
You will also notice that the routine address returned from GetProcAddress has to be cast into to the procedural type that we want to work with - in this case PICKICONDLGPROC If we don't do this the compiler will complain that it cannot convert from one procedural type to another.
Steve.