Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ACCESSING METHOD EXPORT in CLASS in DLL

ACCESSING METHOD EXPORT in CLASS in DLL

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Killer3
    wrote on last edited by
    #1

    Can i have a sample code that achieves it? class __declspec(dllexport) MyClass { public: static char* LSGDecrypt(const char* key,const char* hex); static char* LSGEncrypt(const char* key,const char* source); } The above class is export in a dll . So should i add new function to the dll ? Iam about access a static function So is that required to instantiate the class object. HINSTANCE hDLL; // Handle to DLL LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer char* key = new char [50]; key ="KEYVAULE"; char* strPlain = new char [50]; strPlain="password"; char* strResult = new char [50]; DWORD dwrd =NULL; hDLL = LoadLibrary("Mydll.dll"); if (hDLL != NULL) { lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,"LSGEncrypt"); if (lpfnDllFunc1 ==NULL) // Fails here? so DLL is freed up? { FreeLibrary(hDLL); } else strResult = lpfnDllFunc1("killer" ,"strikes HERE"); } for thendral

    T 1 Reply Last reply
    0
    • K Killer3

      Can i have a sample code that achieves it? class __declspec(dllexport) MyClass { public: static char* LSGDecrypt(const char* key,const char* hex); static char* LSGEncrypt(const char* key,const char* source); } The above class is export in a dll . So should i add new function to the dll ? Iam about access a static function So is that required to instantiate the class object. HINSTANCE hDLL; // Handle to DLL LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer char* key = new char [50]; key ="KEYVAULE"; char* strPlain = new char [50]; strPlain="password"; char* strResult = new char [50]; DWORD dwrd =NULL; hDLL = LoadLibrary("Mydll.dll"); if (hDLL != NULL) { lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,"LSGEncrypt"); if (lpfnDllFunc1 ==NULL) // Fails here? so DLL is freed up? { FreeLibrary(hDLL); } else strResult = lpfnDllFunc1("killer" ,"strikes HERE"); } for thendral

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      R.ilan thendral wrote:

      INSTANCE hDLL; // Handle to DLLLPFNDLLFUNC1 lpfnDllFunc1; // Function pointerchar* key = new char [50];key ="KEYVAULE";char* strPlain = new char [50];strPlain="password";char* strResult = new char [50];DWORD dwrd =NULL;hDLL = LoadLibrary("Mydll.dll");if (hDLL != NULL){lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,"LSGEncrypt");if (lpfnDllFunc1 ==NULL) // Fails here? so DLL is freed up?{FreeLibrary(hDLL); }elsestrResult = lpfnDllFunc1("killer" ,"strikes HERE");}

      You can use Exported class this way, because the function have no memory till the Classobject is created.this method is only used to load Dll function. for loading class from DLL, first you have to create MFC extention DLL,secondly you can try this article... http://www.codeproject.com/dll/noextensiondll.asp

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups