Calling ShellExecute to open a URL in the default browser
Simen kjaeraas
simen.kjaras at gmail.com
Wed Aug 4 01:47:46 PDT 2010
Daniel Worthington <daniel.worthington at gmail.com> wrote:
> 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
Move your declaration of ShellExecuteW outside main, and it will work:
import std.c.windows.windows;
extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR,
LPCWSTR, LPCWSTR, INT);
int main(string[] args) {
HINSTANCE i = ShellExecuteW(null, "open",
"http://www.example.com", null, null, SW_SHOW);
return 0;
}
This should work, though, so I'm filing a bug on it:
http://d.puremagic.com/issues/show_bug.cgi?id=4581
--
Simen
More information about the Digitalmars-d-learn
mailing list