1. I need help fixing an error
- Posted by Jeff Fielding <JJProg at CYBERBURY.NET>
Mar 24, 1997
-
Last edited Mar 25, 1997
When I run my program (the one that uses the Browse for folder dialog), I
continuously get the same error message (shown in the code below). Euphoria
doesn't give me eny error message, or create an ex.err file. The error says
that Exw caused a page fault at ....
-- CODE STARTS HERE
include win32lib\win32lib.ew -- I have placed win32lib in a seperate
directory
include dll.e
include machine.e
-- include msgbox.e is not used
-- create the interface
constant w = create(Window,"Configure Renamer
2.0",0,Default,Default,450,340,0)
constant frame1 = create(Group,"Rename Files",w,2,0,440,110,0)
constant frame2 = create(Group,"From",w,5,15,430,45,0)
constant text1 = create(EditText,"",w,10,30,360,20,0)
constant command1 = create(PushButton,"Browse",w,378,30,52,20,0)
constant frame3 = create(Group,"To",w,5,59,430,45,0)
constant text2 = create(EditText,"",w,10,74,360,20,0)
constant command2 = create(PushButton,"Browse",w,378,74,52,20,0)
wPosition(2,110)
wPuts("Valid Characters:")
constant text3 = create(EditText,"",w,117,110,320,20,0)
constant frame4 = create(Group,"Filenames not to use",w,2,135,440,150,0)
constant list1 = create(List,"",w,10,150,175,140,0)
constant text4 = create(EditText,"",w,190,150,200,20,0)
constant command3 = create(PushButton,"Add",w,190,180,200,20,0)
constant command4 = create(PushButton,"Remove",w,190,210,200,20,0)
constant command5 = create(PushButton,"OK",w,2,290,50,20,0)
constant command6 = create(PushButton,"Roll-Over Counter",w,62,290,125,20,0)
constant command7 = create(PushButton,"About",w,197,290,50,20,0)
constant command8 = create(PushButton,"Close",w,257,290,50,20,0)
-- Constants for the dialog
constant BIF_RETURNONLYDIRS = #1
constant MAX_PATH = 260
constant SHELL_DLL = open_dll("shell32.dll")
constant OLE_DLL = open_dll("ole32.dll")
constant USER_DLL = open_dll("user32.dll")
constant GETACTIVEWINDOW =
constant COTASKMEMFREE = define_c_proc(OLE_DLL,"CoTaskMemFree",{C_LONG})
constant SHBROWSEFORFOLDER = define_c_func(SHELL_DLL,"SHBrowseForFolderA",
{C_POINTER},C_LONG)
constant SHGETSPECIALFOLDERLOCATION = define_c_func(SHELL_DLL,
constant SHGETPATHFROMIDLIST =
define_c_func(SHELL_DLL,"SHGetPathFromIDListA",
{C_LONG,C_POINTER},C_LONG)
-- Structure
constant SHITEMID_CB = 0
constant SHITEMID_ABID = 4
constant SIZEOF_SHITEMID = 8
-- Structure
constant BROWSEINFO_HOWNER = 0
constant BROWSEINFO_PIDLROOT = 4
constant BROWSEINFO_PSZDISPLAYNAME = 8
constant BROWSEINFO_LPSZTITLE = 12
constant BROWSEINFO_UFLAGS = 16
constant BROWSEINFO_LPFN = 20
constant BROWSEINFO_IIMAGE = 24
constant SIZEOF_BROWSEINFO = 28
constant NOERROR = 0
-- Return the HWND of the active window
function GetHWnd()
return c_func(GETACTIVEWINDOW,{})
end function
-- There is an error in this procedure.
-- "Application Error: C:\EUPHORIA\BIN\EXW.EXE
--The instruction at 01000004 referenced memory at 01000004
--The memory could not be read from
--Click on OK to terminate the application
--Exw
--This program has performed an illegal operation
--and will be shut down....
--Details:
--EXW caused an invalid page fault in
--module <unknown> at 0000:01000004.
--Registers:
--EAX=00000000 CS=0137 EIP=01000004 EFLGS=00010202
--EBX=00000ae8 SS=013f ESP=0056f0f0 EBP=0056f230
--ECX=0056f504 DS=013f ESI=bff64db6 FS=0f87
--EDX=01000004 ES=013f EDI=0056f504 GS=0000
--Bytes at CS:EIP:
--Stack dump:
--70986d10 00000ad8 00000001 00000000 bff62e82 709877bb 0056f504 00000001
--0000000 00000000 000082c4 0056f2a0 000005ae 0577b78a 002a00bd 00080000
procedure Command1_OnClick(integer x, integer y)
atom bi
atom nfolder
atom idl
atom pidl
atom s1, s2, s3, t
sequence s
bi = allocate(SIZEOF_BROWSEINFO)
idl = allocate(SIZEOF_SHITEMID)
nfolder = 0
poke4(bi+BROWSEINFO_HOWNER,GetHWnd())
if c_func(SHGETSPECIALFOLDERLOCATION,{GetHWnd(),nfolder,idl}) = NOERROR
then
poke(bi+BROWSEINFO_PIDLROOT,peek({idl,4}))
end if
s1 = allocate_string(repeat(0,MAX_PATH))
s2 = allocate_string("Rename from:")
poke4(bi+BROWSEINFO_PSZDISPLAYNAME,s1)
poke4(bi+BROWSEINFO_LPSZTITLE,s2)
poke4(bi+BROWSEINFO_UFLAGS,BIF_RETURNONLYDIRS)
pidl = c_func(SHBROWSEFORFOLDER,{bi})
if pidl != 0 then
s3 = allocate_string(repeat(0,MAX_PATH))
t = c_func(SHGETPATHFROMIDLIST,{pidl,s3})
-- The error seems to be around here because I first got the error after
entering the marked statements (with --)
s = {} --
for i = 0 to MAX_PATH-1 do --
if peek(s3+i) = 0 then --
exit --
else --
s = s & peek(s3+i) --
end if --
end for --
setText(text1,s) --
c_proc(COTASKMEMFREE,{pidl})
free(s3)
end if
free(s1)
free(s2)
free(bi)
free(idl)
end procedure
onClick[command1] = routine_id("Command1_OnClick")
WinMain(w)
-- CODE ENDS HERE
Thanks,
Jeffrey Fielding
JJProg at cyberbury.net