Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:08:28+00:00 2026-06-13T01:08:28+00:00

I used msdn documentation here: http://msdn.microsoft.com/en-us/library/f0fkfy9y(v=vs.100).aspx It specifies there that: case dliNotePreLoadLibrary : //If

  • 0

I used msdn documentation here: http://msdn.microsoft.com/en-us/library/f0fkfy9y(v=vs.100).aspx

It specifies there that:

case dliNotePreLoadLibrary :
//If you want to return control to the helper, return 0.
//Otherwise, return your own HMODULE to be used by the 
//instead of having it call LoadLibrary itself

So I tried the following:

FARPROC WINAPI delayHook(unsigned dliNotify, PDelayLoadInfo pdli)
{
    switch (dliNotify) {
        case dliStartProcessing :
        case dliNotePreGetProcAddress :
        case dliFailLoadLib :
        case dliFailGetProc :
        case dliNoteEndProcessing : 
          return 0;
          break;
        case dliNotePreLoadLibrary :
            {
                char* dllPath = getDllPath();
                HMODULE lib = LoadLibrary(dllPath);
                return lib;
            }
            break;      
        default :
            return NULL;
    }
    return NULL;
}

I get error for returning the HMODULE:

‘return’ : cannot convert from ‘HMODULE’ to ‘FARPROC’.

What is the problem? Am I doing something worng? they do say return your own HMODULE, and that is what I did…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:08:32+00:00Added an answer on June 13, 2026 at 1:08 am

    LoadLibrary() returns an HMODULE. Your delayHook() function returns a FARPROC. So there is a mismatch in return value.
    Assuming that you really want to return HMODULE returned by LoadLibrary(), you may want to use a cast like reinterpret_cast:

    case dliNotePreLoadLibrary :
    {
        char* dllPath = getDllPath();
        HMODULE lib = LoadLibrary(dllPath);
        return reinterpret_cast<FARPROC>(lib);
    }
    

    Side note: in today’s world, you should use Unicode instead of ANSI/MBCS, so your dllPath should better be a Unicode string (e.g. const wchar_t*, or CString, or std::wstring).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used this MSDN example to construct my console host app: http://msdn.microsoft.com/en-us/library/ms731758.aspx It works
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
I used the step-by-step building application from the http://msdn.microsoft.com/en-us/library/hh202876(v=vs.92).aspx but the .sdf file won't
First, we have InterlockedExchange64(); http://msdn.microsoft.com/en-us/library/windows/desktop/ms683593%28v=vs.85%29.aspx LONGLONG __cdecl InterlockedExchange64( __inout LONGLONG volatile *Target, __in LONGLONG
Ok, I have a problem with the MSDN documentation for the namespace Microsoft.Office.Interop.Excel .
According to the MSDN documentation , a ribbon:RibbonControlSizeDefinition can be used to control the
The msdn documentation of the System.IDisposable interface states that The primary use of this
It states in the MSDN documentation that: at the very minimum, your state parameter
The MSDN documentation doesn't explain in detail what its used for. Since its optional,
Per the MSDN documentation , the following syntax is used: // A read-write instance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.