0

I have an application with a dependency on gdiplus.dll. However, on Windows 2000, since there is no gdiplus.dll (I don't want to ship with the app....asking the user to download is what i want), the exe throws an error (this looks like a system error) saying gdiplus.dll was not detected in the system in the std search paths.

Is there a way to detect and throw a custom dialog before this system error, asking the user to download gdiplus.dll and then try again?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

Just search the PATH environment variable for it. In MS-Windows you can do it like this

#include <iostream>
#include <windows.h>
#include <string>
#include <cstdio>
#include <sstream>
using namespace std;

bool search(string path)
{
    WIN32_FIND_DATA data;
    path += "\\gdiplus.dll";
    HANDLE hFind = FindFirstFile(path.c_str(), &data);
    if(hFind != INVALID_HANDLE_VALUE)
    {
        FindClose(hFind);
        return true;
    }
    return false;
}

int main()
{
    char *buf = 0;
    size_t len = 0;
    errno_t err = _dupenv_s(&buf, &len, "PATH");
    if(err == -1)
    {
        cout << "Error getting PATH\n";
        return 1;
    }
    stringstream str(buf);
    string path;
    while( getline(str,path,';') )
    {
        if( search(path) )
        {
            cout << "Found at: \"" << path << "\"\n";
            break;
        }
    }
    free(buf);

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.