function DelDirectory(const Source: string): boolean;
var
  fo: TSHFILEOPSTRUCT;
begin
  FillChar(fo, SizeOf(fo), 0);
  with fo do
  begin
    Wnd := 0;
    wFunc := FO_DELETE;
    pFrom := PChar(source+#0);
    pTo := '';
    fFlags := FOF_NOCONFIRMATION + FOF_SILENT+FOF_ALLOWUNDO+FOF_NOERRORUI;
    fAnyOperationsAborted:=False;
  end;
  Result := (SHFileOperation(fo) = 0);
end;
下面语句为什么老是提示“Access violation at address 00420ef3 in module xxx.exe. Read of address 00000000 process stopped”?但是如果没有最后两行,却没有错误?
  wjj:= 'c:\test';
  if directoryexists(wjj) then
   DelDirectory(kswjj);  if not directoryexists(kswjj) then
     CreateDir(kswjj);