Hello developers,
I have been playing around with C++ and wxWidgets for a little time now and I think it is time to make a little useful program I am planning to make a CD ripper and Encoder (re-inverting the wheel purposely for learning) and I plan to use CDRip.dll or Akrip32.dll as rippers and Lame as Encoder. Alot of words anyway here comes a question:

1. How do I load dll functions in My C++ program and use their function

2. Any good example on CD ripping or Encoding?

I'm trying to follow the tutorial here but it is for VB
http://www.vbaccelerator.com/home/VB/code/vbMedia/Audio/CD_Ripping_1/article.asp

Hope to benefit from your experiences guys :)
Cheers

Recommended Answers

All 6 Replies

You won't be reinventing the wheel if your using dlls from other software to make it. It will just basically be organizing and making your own GUI. If you really want to "Reinvent the Wheel" then make EVERYTHING yourself.
But it will be pretty hard to use the dlls unless you have a lib.

Hehehe, I meant that others have done this too ;)
Anyway ho do I go about it?

Ok,
I think I need someone to help me to get up and running with DLLs.
I have googled for Tutorial, but I find difficult to follow much of tutorials. They just do a lot in advanced way and I'm just a new bee :)

Hi,
after some roaming around MSDN library, I got some light on DLLs issues. Then I tried to make DLL and call it in simple app. But the call produces weird strange results. What is wrong with the code?

Also when I make new DLL project in code::blocks, code::blocks gives a code by default. I don't understand most of IFDEFs it writes!

My DLL Code is:
main.h

#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>

/*  To use this exported function of dll, include this header
 *  in your project.
 */

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif


#ifdef __cplusplus
extern "C"
{
#endif

DLL_EXPORT double Add(double a, double b);

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__
#include "main.h"
# include<iostream>
using namespace std;

// a sample exported function
DLL_EXPORT double Add(double a, double b)
{
    cout<<"DLL got called!"<<endl;
   return(a+b);
}

Application that call the DLL

// MyExecRefsDll.cpp
// compile with: /EHsc /link MathFuncsDll.lib

#include <iostream>

#include "windows.h"

using namespace std;
//dll stuffs
typedef double (*AddFunc)(int a, int b);

int main()
{
    //declare the pointers to DLL functions
    AddFunc Add;
    HINSTANCE ourlib = LoadLibrary("math.dll");
    if (ourlib==NULL)
    {
        FreeLibrary(ourlib);
    }

    else
    {
        Add = (AddFunc)GetProcAddress(ourlib, "Add");
        double a = 7.4;
        double b = 99.6;

        cout << "a + b = " <<
            Add(a, b) << endl;
        /*cout << "a - b = " <<
            MathFuncs::MyMathFuncs::Subtract(a, b) << endl;
        cout << "a * b = " <<
            MathFuncs::MyMathFuncs::Multiply(a, b) << endl;
        cout << "a / b = " <<
            MathFuncs::MyMathFuncs::Divide(a, b) << endl; */
            FreeLibrary(ourlib);
            cin.get();
        return 0;
    }
}

Since there is no answer, I think I have to open separate thread for DLL Issues.
Thank All!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.