Re: Accessviolation
- From: "HarryS" <herrs4remove@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 7 Dec 2008 16:21:59 -0600
Following is a little of the background code that led to the AV. Note that
I misstated in my original post that the form was named Form2Dlg - it was
CopyNDlg.
Following is from the source file:
<snip>
begin
Application.Title := 'Program Setup';
Application.CreateForm(TInstallDlg, InstallDlg);
Application.CreateForm(TDriveNDlg, DriveNDlg);
Application.CreateForm(TCopyNDlg, CopyNDlg);
Application.CreateForm(TGroupNDlg, GroupNDlg);
Application.CreateForm(TDecompMessage, DecompMessage);
Application.CreateForm(TPriorInstallDlg, PriorInstallDlg);
Application.CreateForm(TAdminDlg, AdminDlg);
Application.Run;
end.
<end snip>
InstallDlg opens first, with no content.
DriveNDlg opens next centered in InstallDlg. DriveNDlg basically has an
edit control and OK, Cancel, Browse, and Help buttons.
When the OK btn on DriveNDlg is clicked, the following code executes in the
event:
<snip>
procedure TDriveNDlg.OKBtnClick(Sender: TObject);
var
p1 : pchar;
CSize : string;
Button : integer;
FileThere : boolean;
DirString, Dir, FontDir : string;
TimeUsed : TIniFile;{moved winsyspath and path to opening.pas}
filename, fname : string;
a : byte;
error : longint;
FileHandle, dateage : integer;
reg: TRegistry;
begin
Label1.Hide;
Label3.Hide;
Edit1.Hide;
Edit2.Hide;
BrowseBtn.Hide;
Label2.Transparent := false;
{make sure we're not installing to floppy drive}
if DriveNDlg.Edit2.Text[1] in ['A', 'B', 'a', 'b'] then begin
MessageDlg('You must install this application to a hard drive . . .',
mtError,
[mbOk], 0);
CopyNDlg.Hide;
BrowseBtn.Show;
DriveNDlg.Label1.Show;
DriveNDlg.Label3.Show;
DriveNDlg.Edit1.Show;
DriveNDlg.Edit2.Show;
Exit;
end; {A or B drive}
if NOT FoundOldInstall then
if SysUtils.DirectoryExists(DriveNDlg.Edit2.Text) then begin
if Length(DriveNDlg.Edit2.Text) <> 3 then begin
if MessageDlg(DriveNDlg.Edit2.Text + ' already exists. Proceed?',
mtConfirmation, [mbYes, mbNo], 0) = mrNo then
begin
CopyNDlg.Hide;
BrowseBtn.Show;
DriveNDlg.Label1.Show;
DriveNDlg.Label3.Show;
DriveNDlg.Edit1.Show;
DriveNDlg.Edit2.Show;
Exit;
end; {if NO}
end; {if <> 3}
end else
CreatePath(DriveNDlg.Edit2.Text);
if SysUtils.DirectoryExists(DriveNDlg.Edit2.Text) AND
(Length(DriveNDlg.Edit2.Text) = 3) then begin
{see if we're installing to the root directory}
if MessageDlg(DriveNDlg.Edit2.Text + ' is the root directory.
Proceed?',
mtConfirmation, [mbYes, mbNo], 0) = mrNo then
begin
BrowseBtn.Show;
CopyNDlg.Hide;
DriveNDlg.Label1.Show;
DriveNDlg.Label3.Show;
DriveNDlg.Edit1.Show;
DriveNDlg.Edit2.Show;
Exit;
end;
end;
{make sure we're not installing onto ourselves}
if DriveNDlg.Edit2.Text = JustPathName(ParamStr(0)) then begin
MessageDlg('The source and destination directories cannot be the
same!', mtError,
[mbOk], 0);
CopyNDlg.Hide;
BrowseBtn.Show;
DriveNDlg.Label1.Show;
DriveNDlg.Label3.Show;
DriveNDlg.Edit1.Show;
DriveNDlg.Edit2.Show;
Exit;
end;
CopySize := 4888182 - 4096;
TotalSize := 10914830;
if NOT EnoughDiskSpaceForInstall(TotalSize) then begin
Str(TotalSize,CSize);
MessageDlg('This application requires at least '+CSize+' bytes of
disk space. Be sure that you have at least '+CSize+
' bytes free and rerun SETUP.', mtError,[mbOK], 0);
{will only terminate after completing this block, ergo, the
following Exit}
Application.Terminate;
Exit;
end;
InstallDlg.Cursor := crHourGlass;
//CopyNDlg.Cursor := crHourGlass; <---- Initially, the access violation
occurred here, so I commented it out,
// recompiled and when retested on
Win 2000, the AV jumped where indicated below. This
// led to the suspicion that maybe
CopyNDlg didn't actually exist?
DriveNDlg.Cursor := crHourGlass;
Label2.Caption := '
'+
' '+
'SETUP is copying the Application files to your hard drive. Please be
patient . . .';
label2.Update;
DriveNDlg.Caption := Edit2.Text;
CopyNDlg.Show; {<------ After commenting out the line above, the code
execution jumped from here to the code in
the TCustomForm.SetVisible procedure in the VCL Forms
unit where the AV occurred as indicated in
my original post, leading me to think that CopyNDlg
wasn't actually created. Keep in mind that
this all works fine on XP and Vista.}
CopyNDlg.Label1.Caption := 'Copying file README.1ST . . .'; {4964 bytes}
CopyNDlg.Label1.Update;
QuickCopy('Readme.1st', DriveNDlg.Edit2.Text);
CopyNDlg.Gauge1.Update;
<end snip>
//then, additional stuff from here to end of OnClick event...
.
- Follow-Ups:
- Re: Accessviolation
- From: Skybuck Flying
- Re: Accessviolation
- From: Jamie
- Re: Accessviolation
- References:
- Accessviolation
- From: HarryS
- Accessviolation
- Prev by Date: Re: Accessviolation
- Next by Date: Re: Accessviolation
- Previous by thread: Re: Accessviolation
- Next by thread: Re: Accessviolation
- Index(es):
Loading