interface function MakeSureDirectoryPathExists(DirPath: LPCSTR): Bool; stdcall; implementation function MakeSureDirectoryPathExists; external 'IMAGEHLP.DLL' name 'MakeSureDirectoryPathExists';DirPath にはファイル名を指定します。 パスの最後のコンポーネントがファイル名ではなくディレクトリである場合、文字列の最後に円記号(\)を記述しなければなりません。 このAPIは失敗すると False を返します。 こんな感じになります
procedure TForm1.Button1Click(Sender: TObject);
begin
if not MakeSureDirectoryPathExists(PChar('c:temp')) then
raise Exception.Create('Cannot create c:temp');
end;
補足
この記事にはトラックバック・コメントがありません。
サイト管理者はコメントに関する責任を負いません。