digitalmars.D.learn - ShellExecute
- Serj Makaroff (12/12) Feb 11 2008 Hello!
- Simen Kjaeraas (10/23) Feb 11 2008 w
- Serj Makaroff (3/3) Feb 11 2008 Thank you! It's work.
- Sergey Gromov (15/19) Feb 11 2008 There is no such Windows function like ShellExecute(). There is
- doob (5/27) Feb 11 2008 From the language specification: "Export means that any code outside
- Sergey Gromov (8/22) Feb 12 2008 Thanks. I did know what the specs were saying, I was just wondering if
- torhu (12/17) Feb 12 2008 I guess you're supposed to use it where you'd use __declspec(dllimport)
- Sergey Gromov (7/10) Feb 16 2008 This explains it, thanks. This also means that export is sometimes also...
- torhu (6/14) Feb 16 2008 This guide mostly explains it:
- Jarrett Billingsley (7/12) Feb 12 2008 I think it's used when exporting a symbol _from_ a library/app (i.e. as ...
- Matti Niemenmaa (8/10) Feb 11 2008 ShellExecute is a macro, #defined somewhere in windows.h as either Shell...
Hello! I try to use WinAPI function ShellExecute() to start web browser in new process. I wrote such definition export { HINSTANCE ShellExecute(HWND hwnd,LPCTSTR lpOperation,LPCTSTR lpFile,LPCTSTR lpParameters,LPCTSTR lpDirectory,INT nShowCmd); } and called function in such way: HINSTANCE i = ShellExecute(null, mode, url, null, null, SW_SHOW); Also I found in MSDN, that this function is in shell32.dll. I added pragma(lib, "shell32.lib"); I obtain linker error "Symbol Undefined..." Help, pls
Feb 11 2008
On Mon, 11 Feb 2008 19:18:27 +0100, Serj Makaroff = <serj-makaroff yandex.ru> wrote:Hello! I try to use WinAPI function ShellExecute() to start web browser in ne=wprocess. I wrote such definition export { HINSTANCE ShellExecute(HWND hwnd,LPCTSTR lpOperation,LPCTSTR =lpFile,LPCTSTR lpParameters,LPCTSTR lpDirectory,INT nShowCmd); } and called function in such way: HINSTANCE i =3D ShellExecute(null, mode, url, null, null, SW_SHOW); Also I found in MSDN, that this function is in shell32.dll. I added pragma(lib, "shell32.lib"); I obtain linker error "Symbol Undefined..." Help, plsWhen changing the definition to extern (Windows) { HINSTANCE ShellExecuteA(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT); HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT);= } this works for me.
Feb 11 2008
Thank you! It's work. But why ShellExecute() doesn't work and what is the difference between ShellExecuteA() and ShellExecuteW()?
Feb 11 2008
Serj Makaroff <serj-makaroff yandex.ru> wrote:Thank you! It's work. But why ShellExecute() doesn't work and what is the difference between ShellExecuteA() and ShellExecuteW()?There is no such Windows function like ShellExecute(). There is ShellExecuteA() which accepts ASCII (CHAR/CHAR*) parameters and returns compatible results, and ShellExecuteW() which accepts Unicode (WCHAR/WCHAR*) parameters and returns accordingly. The ShellExecute is a macro defined in windows.h for C preprocessor, there is no such symbol in the OS. This macro expands to either of the former functions depending on whether the _UNICODE macro is defined. This holds true for most of Windows API. This reminds me: why all the standard D headers declare Windows functions as extern(Windows) export void SomeApiFunction() ? What's the use for export attribute ? -- SnakE
Feb 11 2008
Sergey Gromov wrote:Serj Makaroff <serj-makaroff yandex.ru> wrote:From the language specification: "Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL." Tango doesn't use export with win api functionsThank you! It's work. But why ShellExecute() doesn't work and what is the difference between ShellExecuteA() and ShellExecuteW()?There is no such Windows function like ShellExecute(). There is ShellExecuteA() which accepts ASCII (CHAR/CHAR*) parameters and returns compatible results, and ShellExecuteW() which accepts Unicode (WCHAR/WCHAR*) parameters and returns accordingly. The ShellExecute is a macro defined in windows.h for C preprocessor, there is no such symbol in the OS. This macro expands to either of the former functions depending on whether the _UNICODE macro is defined. This holds true for most of Windows API. This reminds me: why all the standard D headers declare Windows functions as extern(Windows) export void SomeApiFunction() ? What's the use for export attribute ?
Feb 11 2008
doob <doobnet gmail.com> wrote:Sergey Gromov wrote:Thanks. I did know what the specs were saying, I was just wondering if I missed something. I also know that it does work without `export'--- because I've tried. Is it a left-over from an earlier versions of the language ? The example-driven programmers keep copying this code around, making it sort of common practice... -- SnakEThis reminds me: why all the standard D headers declare Windows functions as extern(Windows) export void SomeApiFunction() ? What's the use for export attribute ?From the language specification: "Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL." Tango doesn't use export with win api functions
Feb 12 2008
Sergey Gromov wrote: > Thanks. I did know what the specs were saying, I was just wondering ifI missed something. I also know that it does work without `export'--- because I've tried. Is it a left-over from an earlier versions of the language ? The example-driven programmers keep copying this code around, making it sort of common practice...I guess you're supposed to use it where you'd use __declspec(dllimport) in C, but it I'm not sure why it works anyway for functions. It's possible that it's not needed since a function prototype can never be a definiton. So it's safe for the linker to resolve it to a function in the import library (.lib). Unless the function is defined in another module you're linking with. Not sure what happens then, maybe you just get that function instead of the one in the dll. It's needed when linking to variables that are in a DLL, though. If you don't add it, even variable declarations with the 'extern' storage class will turn into definitions.
Feb 12 2008
torhu <no spam.invalid> wrote:It's needed when linking to variables that are in a DLL, though. If you don't add it, even variable declarations with the 'extern' storage class will turn into definitions.This explains it, thanks. This also means that export is sometimes also import because extern is not actually for an extern symbol but merely a calling convention specifier. I can live with that. :) -- SnakE
Feb 16 2008
Sergey Gromov wrote:torhu <no spam.invalid> wrote:This guide mostly explains it: http://www.digitalmars.com/d/2.0/htomodule.html And yes, 'export' is used for imports too. Just 'extern' works like in C, while 'extern (XYZ)' is really an unrelated feature.It's needed when linking to variables that are in a DLL, though. If you don't add it, even variable declarations with the 'extern' storage class will turn into definitions.This explains it, thanks. This also means that export is sometimes also import because extern is not actually for an extern symbol but merely a calling convention specifier.
Feb 16 2008
"Sergey Gromov" <snake.scaly gmail.com> wrote in message news:MPG.221c192f273aa432989691 news.digitalmars.com...Thanks. I did know what the specs were saying, I was just wondering if I missed something. I also know that it does work without `export'--- because I've tried. Is it a left-over from an earlier versions of the language ? The example-driven programmers keep copying this code around, making it sort of common practice...I think it's used when exporting a symbol _from_ a library/app (i.e. as a symbol to export from a DLL, which does actually work), but when dealing with external symbols, I'm not entirely sure what it's supposed to do. I suppose if it works fine without it, there's no need for it. It might just be one of those cases where D ignores spurious protection attributes.
Feb 12 2008
Serj Makaroff wrote:But why ShellExecute() doesn't work and what is the difference between ShellExecuteA() and ShellExecuteW()?ShellExecute is a macro, #defined somewhere in windows.h as either ShellExecuteA or ShellExecuteW depending on whether you're using Unicode or not. Many Windows functions are similar #defines. If something doesn't link out of the box, try appending A or W (whichever is the one you want): most of the time it solves the problem. -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Feb 11 2008