Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'dll'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 3 results

  1. Hi, Can someone please help me with this code which just calls a DLL. The code works perfectly in the Dev-C++ IDE but gives me an error indicating that the LoadLibrary/GetProcessAddress fails when I try to execute it in the MS Visual C++ (2008 express) IDE. // A simple program that uses LoadLibrary and // GetProcAddress to access the printString function from HelloWorld_CPP.dll. // It also calls the function in the DLL passing a string to it. #include <stdafx.h> #include <windows.h> #include <stdio.h> #include <iostream> #include <string> #include <comdef.h> // needed to use LPCSTR typedef int (__cdecl *MYPROC)(LPCSTR); /* LP == long pointer. Just think pointer or char* C = const in this case I think they mean the character string is a const, not the pointer being const. STR is string (UTF-8 I think (one byte per character)) */ LPCSTR getInputString(void) { std::string theString; // define the variable to hold the string // std::cin.ignore(100, '\n'); // clear out the input buffer std::cout << "Enter the string\n"; std::getline(std::cin, theString); // get a whole sentence LPCSTR newString = theString.c_str(); // convert the entered string to LPCSTR format return newString; } int main(void) { HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary(TEXT("E:\\Documents\\Visual Studio 2008\\Projects\\DLL_Test\\HelloWorld_CPP.dll")); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcAdd = (MYPROC) GetProcAddress(hinstLib, "printString"); // If the function address is valid, call the function. if (NULL != ProcAdd) { fRunTimeLinkSuccess = TRUE; // OK, now get the string from the user console LPCSTR aString = getInputString(); (ProcAdd) (aString); // (ProcAdd) ("Message sent to the DLL function"); // the string that gets 'sent' to the function in the dll } // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); } // If unable to call the DLL function, use an alternative. if (! fRunTimeLinkSuccess) { printf("Unable to call the dll\n"); std::cin.get(); return 1; } } The environment is Windows 7, 64 bit. Any assistance will be most appreciated. Best regards, Necuima.
  2. Hi, I thought that I'd post another of my 'lessons learned' - this time interfacing between a C++ dll (though I suppose it doesn't need to be a dll) and Image Magick. After much Googling it seems that there are 3 ways for a C++ program to invoke Image Magick functionality: 1) via the 'core' C API 2) via Magick++ 3) via Wand In my case I only wanted basic Image Magick functions. I eventually found a nice simple example which showed the difference between approach 1) and approach 3). Approach 3 - i.e., via Wand was far simpler. I could not get approach 2 to work for me at all but I'm sure that someone knowledgeable could. So I proceeded to experiment with the Wand interface. I am using Visual C++ 2008 Express Edition as my IDE. There is some very good advice re the settings that you need to make in the IDE so that the compiler and linker can find the files they need - see http://www.imagemagick.org/discourse-server/viewtopic.php?t=11757 and in particular el_supremo's post dated 2008-07-26T08:05:28-07:00. My C++/Wand code just reads in a jpg image file, sets size and quality parameters and then writes the resized file out with its new size and quality and a new file name, all using Wand methods. It took me about 3 weeks and hundreds of Google searches to get to this outcome, or maybe I'm just a slow learner :-) Cheers from Oz.
  3. Hi, I hope that this is not 'too simple' for anyone replying, but I'm a C novice so your advice will be most appreciated. The background is that I'm trying to learn about DLLs and using them in a Windows 7 environment. I have created a simple 'HelloWorld-ish' DLL in C which compiles OK. It is meant to receive a string passed to it from a calling C++ program and display that string in a messagebox. I am aware that strings are handled differently in C and C++. I suspect that my 'caller' program is passing the string OK but that my C DLL is not handling it OK. The DLL displays just the first character of the passed string. Here's the code from the DLL - first the dll.h: #ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ DLLIMPORT void HelloWorld (char *str_in); #endif /* _DLL_H_ */ And the HelloWorld.c code: #include "E:/documents/C_PlusPlus/HelloWorld_C/dll.h" #include <windows.h> #include <stdio.h> #include <stdlib.h> DLLIMPORT void HelloWorld (char *str_in) { MessageBox (0, str_in, "Try 2", MB_ICONINFORMATION); } BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; } My environment in this context is Windows 7 64 bit and Dev-C++ I have scoured the Internet and forums but I can't seem to find what I'm looking for. Any advice will be most appreciated and thank you in anticipation. Cheers
×
×
  • Create New...