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 6768339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:03:48+00:00 2026-05-26T15:03:48+00:00

I was thinking it would be cool to have a few classes to wrap

  • 0

I was thinking it would be cool to have a few classes to wrap around LoadLibrary and GetProcAddress, Library and Function respectively. As I was thinking about this I’m not sure its possible. Here is what I’m thinking:

Library class:

class Library
{
    HANDLE m_handle;
public:
    // Handles initializing the DLL:
    Library(std::string name);
    // Deinitializes the DLL
    ~Library();

    HANDLE getHandle();
    bool isInitialized();
}

And the Function class:

class Function
{
public:
    Function(Library& library, std::string name);


    void* call(/* varg arguments? */) throw(exception);

    bool isValid();
}

Problem arises because I have to have dynamic data types for the parameters and multiple lengths to pass to the real function pointer. I could get around the multiple lengths of the arguments by specifying it in the constructor and have specific methods but what about the data types?

EDIT: I’ve created classes based on the answers for anyone to use here: https://github.com/ic3man5/ice–

  • 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-05-26T15:03:49+00:00Added an answer on May 26, 2026 at 3:03 pm

    You can implement implicit conversion to a function pointer.

    template <typename Signature>
    struct Function
    {
        Function(Library& library, std::string name)
        {
            m_func = reinterpret_cast<Signature *>(
                ::GetProcAddress(library.m_hModule, name.c_str()));
        }
        operator Signature *() { return m_func; }
    private:
        Signature * m_func;
    };
    

    Use the class as follows:

    Function<int (int, double)> foo(library, "foo");
    int i = foo(42, 2.0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been thinking a lot lately about how cool it would be to have
Just thinking about the best way to build an Order form that would (from
I was thinking about how to create a program that would only be valid
I was thinking that at the top of my partial I would have something
This was just what I was thinking for this solution and I would like
I was thinking it be cool to have a simple matchmaker code in php.
I'm thinking .one would be of use in this situation? but i'm not sure
I was thinking about an idea of auto generated answers, well the answer would
I was thinking it would be super cool if I could hook up something
This is just something I've been thinking about and was wondering if it exists,

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.