Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 14, 2005 win32 build error | ||||
---|---|---|---|---|
| ||||
wchar []ModuleFileName( HMODULE Module ) { wchar []Result; Result.length = 256; //Result.length = GetModuleFileNameW( Module, cast( wchar * )Result, Result.length ) / wchar.sizeof; return Result; } when the commented line remains commented, the application compiles file, but when the line is uncommented, i receive a plethora of errors upon building: C:\dmd\src\phobos\std\c\windows\windows.d(371): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(371): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(371): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(398): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(398): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(399): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(399): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(399): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(401): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(401): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(401): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(402): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(402): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(402): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(403): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(403): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(403): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(1918): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(1918): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(2620): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(2620): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(2620): cannot have parameter of type void C:\dmd\src\phobos\std\c\windows\windows.d(2621): identifier 'HMODULE' is not defined C:\dmd\src\phobos\std\c\windows\windows.d(2621): HMODULE is used as a type C:\dmd\src\phobos\std\c\windows\windows.d(2621): cannot have parameter of type void console_main.d(32): identifier 'HMODULE' is not defined console_main.d(32): HMODULE is used as a type console_main.d(32): cannot have parameter of type void any ideas? |
December 15, 2005 Re: win32 build error - you just needed to declare GetModuleFileNameW() | ||||
---|---|---|---|---|
| ||||
Posted in reply to akcom | In article <dno5bs$2tl4$1@digitaldaemon.com>, akcom says... > >wchar []ModuleFileName( HMODULE Module ) >{ > wchar []Result; > > Result.length = 256; > //Result.length = GetModuleFileNameW( Module, cast( wchar * )Result, >Result.length ) / wchar.sizeof; > > > return Result; >} > >when the commented line remains commented, the application compiles file, but when the line is uncommented, i receive a plethora of errors akcom, this code works: # // winapi1.d # // To Complie: dmd winapi1.d # // Tested on WinXP SP2, with dmd v0.141 # private import std.stdio; # private import std.c.windows.windows; # # extern( Windows ) # HMODULE GetModuleHandleW # ( # /+ IN +/ LPWSTR lpModuleName # ); # # extern( Windows ) # DWORD GetModuleFileNameW # ( # /+ IN +/ HMODULE hModule, # /+ OUT +/ LPWSTR lpFilename, # /+ IN +/ DWORD nSize # ); # # // std.c.windows.windows only has the ASCII version defined: # // DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize); # # wchar[] getModuleFileName( in HMODULE hModule ) # { # wchar[] wResult; # # wResult.length = 256; # wResult.length = # GetModuleFileNameW( hModule, &wResult[0], wResult.length ); # # return wResult; # } # # int main() # { # // If this parameter is NULL, GetModuleHandle returns a handle to the # // file used to create the calling process (.exe file). # writefln("Module filename=\"%s\"", getModuleFileName( cast(HMODULE)null )); # return 0; # } Output: ------- C:\dmd>dmd winapi1.d C:\dmd\bin\..\..\dm\bin\link.exe winapi1,,,user32+kernel32/noi; C:\dmd>winapi1 Module filename="C:\dmd\winapi1.exe" C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html |
December 15, 2005 Re: win32 build error - you just needed to declare GetModuleFileNameW() | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | On Thu, 15 Dec 2005 03:30:56 +0000 (UTC), David L. Davis wrote: > akcom, this code works: [snip] and so does this ... module test; import std.stdio; int main(char[][] pArgs) { writefln("Module filename=\"%s\"", pArgs[0]); return 0; } OUTPUT:::::::: c:\temp>build test -run Path and Version : y:\util\build.exe v2.9(1197) built on Wed Aug 10 11:03:42 2005 y:\dmd\bin\..\..\dm\bin\link.exe test,test.exe,,user32+kernel32,test.def/noi; Module filename="c:\temp\test.exe" -- Derek (skype: derek.j.parnell) Melbourne, Australia "A learning experience is one of those things that says, 'You know that thing you just did? Don't do that.'" - D.N. Adams 15/12/2005 2:34:49 PM |
December 15, 2005 Re: win32 build error - you just needed to declare GetModuleFileNameW() | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | On Thu, 15 Dec 2005 14:41:21 +1100, Derek Parnell <derek@psych.ward> wrote:
> On Thu, 15 Dec 2005 03:30:56 +0000 (UTC), David L. Davis wrote:
>
>> akcom, this code works:
> [snip]
>
> and so does this ...
>
> module test;
> import std.stdio;
> int main(char[][] pArgs)
> {
> writefln("Module filename=\"%s\"", pArgs[0]);
> return 0;
> }
>
> OUTPUT::::::::
>
> c:\temp>build test -run
> Path and Version : y:\util\build.exe v2.9(1197)
> built on Wed Aug 10 11:03:42 2005
> y:\dmd\bin\..\..\dm\bin\link.exe
> test,test.exe,,user32+kernel32,test.def/noi;
> Module filename="c:\temp\test.exe"
IIRC there isn't a guarantee that the first arg is your executable name. Granted most (maybe all existing) prompts/shells define it so, but I suspect it's a habit as opposed to a guarantee.
For example you can write an app which executes the above binary using 'execve' and does not assign the executable filename to the first arg.
Regan
|
Copyright © 1999-2021 by the D Language Foundation