Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 170437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:48:29+00:00 2026-05-11T12:48:29+00:00

I need to know if my program can write files to the disk (HDD,

  • 0

I need to know if my program can write files to the disk (HDD, floppy, flash, CD) from where it is running. I have tried something like:

     {$I-}      Rewrite(myFile);                                             {$I+}   Result:= (IOResult = 0); 

The problem is that if the disk is read-only, Windows gives me an error message telling me that

‘appName.exe – Write Protect Error The disk cannot be written to because it is write protected. Please remove the write protection from the volume USB_BOOT in drive D:. Cancel TryAgain Continue’

How can I test for write access without raising any error/warning messages? Thanks.


Edit:

Ok. The ‘bug’ has nothing to do with the above mentioned piece of code. I only thought that it appears there. I move the code to the read-only disk and ran it from there. The bug appears in a function called ‘CreateShortcutEx’, on this line:

 MyPFile.Save(PWChar(WFileName),False); 

MyPFile is declared like this:

var  MyObject  : IUnknown;  MySLink   : IShellLink;  MyPFile   : IPersistFile;  Directory : String;  WFileName : WideString;  MyReg     : TRegIniFile; begin  MyObject := CreateComObject(CLSID_ShellLink);  MySLink  := MyObject as IShellLink;  MyPFile  := MyObject as IPersistFile;  ..... end; 

So, why is MyPFile trying to write to the application’s drive (the one that is read-only) if the WFileName parameter is ‘C:\documents and settings\bla bla’ ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:48:29+00:00Added an answer on May 11, 2026 at 12:48 pm

    Call the Windows API SetErrorMode() function to disable the error message box.

    Edit:

    I just tried, and this:

    procedure TForm1.Button1Click(Sender: TObject); var   Str: TStream;   OldMode: Cardinal; begin   OldMode := SetErrorMode(SEM_FAILCRITICALERRORS);    try     try       Str := TFileStream.Create('z:\foo.txt', fmOpenReadWrite);       try        finally         Str.Free;       end;     except end;   finally     SetErrorMode(OldMode);   end; end; 

    works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 114k
  • Answers 114k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Jan Miksovsky has an excellent blog on UI design, and… May 11, 2026 at 10:19 pm
  • Editorial Team
    Editorial Team added an answer Cannot understand why it would not work. I used below… May 11, 2026 at 10:19 pm
  • Editorial Team
    Editorial Team added an answer view.layer.cornerRadius = radius; The hard way (that used to be… May 11, 2026 at 10:19 pm

Related Questions

I'm a programmer who has never really used .dll files. Of cause, when I
I have created an application that writes some data to the root folder of
Let's say there's a.gz, and b.gz. $ gzip_merge a.gz b.gz -output c.gz I'd like
I have installed Eclipse and CDT (to use C/C++ in eclipse CDT is needed),

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.