Calling ShellExecute to open a URL in the default browser

Daniel Worthington daniel.worthington at gmail.com
Wed Aug 4 00:53:45 PDT 2010


I am trying to compile the following code using:
dmd test.d
  or
dmd test.d shell32.lib


import std.c.windows.windows;

int main(string[] args) {

    extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR,
LPCWSTR, LPCWSTR, INT);

    HINSTANCE i = ShellExecuteW(null, "open",
"http://www.example.com", null, null, SW_SHOW);

    return 0;

}


In either case I get the following error:

import std.c.windows.windows;

int main(string[] args) {

    extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR,
LPCWSTR, LPCWSTR, INT);

    HINSTANCE i = ShellExecuteW(null, "open",
"http://www.example.com", null, null, SW_SHOW);

    return 0;

}

Error 42: Symbol Undefined
__D4test4mainFAAyaZi13ShellExecuteWMWT4core3sys7windows7windows6HANDLEPxuPxuPxuPxuiZT4core3sys7windows7windows6HANDLE at 24


I think I must be doing something really stupid, and I'm new to D :-)

Daniel


More information about the Digitalmars-d-learn mailing list