August 04, 2010 Calling ShellExecute to open a URL in the default browser | ||||
---|---|---|---|---|
| ||||
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@24 I think I must be doing something really stupid, and I'm new to D :-) Daniel |
August 04, 2010 Re: Calling ShellExecute to open a URL in the default browser | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Worthington | Daniel Worthington <daniel.worthington@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@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 |
Copyright © 1999-2021 by the D Language Foundation