Same Source - different OS - different results. (FileOpen Access Violation WinXP lazarus / 23-Operating Systems ---------------------------------------------------------------------- Ozz_Nixon · 2019-01-30 00:45 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Begin   S:='Hello World!';   Handle:=FileCreate('testing.123',2,438);   FileWrite(Handle,@S[1],Length(S));   FileClose(Handle);End. Run on Mac OSX - Success Run on Linux - Success Run on Windows - "Access Violation" (File Create). * I have tried different 2nd Parameters, I changed to simply FileCreate('testing.123') - same error, same line. If I change code to use Assign(File,'testing.123'); Rewrite(File,1); etc. works on Windows. QuoteFree Pascal Compiler version 3.0.4 [2017/10/06] for i386 Copyright (c) 1993-2017 by Florian Klaempfl and others C:\FPC\3.0.4\bin\i386-Win32\fpc.exe [options] [options] ---------------------------------------------------------------------- engkin · 2019-01-30 01:26 Try: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   S:='Hello World!';  Handle:=FileCreate('testing.123',fmOpenReadWrite or fmShareDenyNone,438);  FileWrite(Handle,S[1],Length(S));  FileClose(Handle); ---------------------------------------------------------------------- Ozz_Nixon · 2019-01-30 02:27 Thanks, tried that too. It is very odd, may be a 3.0.4 issue. I have had very odd problems with I port my working code to Windows. (rarely code for Windows for the past decade, but, this is simple file I/O 102. Ozz ---------------------------------------------------------------------- engkin · 2019-01-30 03:17 Just tested this on WinXp: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes, sysutils  { you can add units after this }; var  S: string;  Handle:THandle;begin  S:='Hello World!';  Handle:=FileCreate('testing.123',fmOpenReadWrite or fmShareDenyNone,438);  FileWrite(Handle,S[1],Length(S));  FileClose(Handle);end. I guess your problem is outside this code. ---------------------------------------------------------------------- Ozz_Nixon · 2019-01-30 17:53 @engkin - thanks, I will synchronize to a newer build than 3.0.4 and see what happens. The code works fine on my Win10 64bit environment. Thank you for your time! Ozz ---------------------------------------------------------------------- engkin · 2019-01-30 19:26 My test is on FPC 3.0.4. Just make sure your file 'testing.123' is not open with another application, or something similar. ---------------------------------------------------------------------- Ozz_Nixon · 2019-01-30 21:21 @engkin ... it is something with "create file" even this raises the same error: (typed off the top of my head, but using old Pascal syntax same error): Assign(BFH,'testing.456'); Rewrite(BFH,1); <--- Access Violation Close(BFH); Again the code works on Linux and Mac, hmmm. ---------------------------------------------------------------------- lucamar · 2019-01-30 21:32 There must be something else wrong in either your program or your system. I've just tested both alternatives in two different machines, with 32 bits Windows XP Home and Professional, with Lazarus/FPC 1.8.4/3.0.4 and they worked as they should. Also tested in Linux and it also works without more ado. ---------------------------------------------------------------------- sash · 2019-01-30 21:52 Quote from: ozznixon on January 30, 2019, 01:45:27 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Begin   S:='Hello World!';   Handle:=FileCreate('testing.123',2,438);   FileWrite(Handle,@S[1],Length(S));   FileClose(Handle);End. Try not to use relaxing defaults:   - Check Handle validity   - Use full path (or explicitly change current directory). ---------------------------------------------------------------------- engkin · 2019-01-30 22:02 Quote from: ozznixon on January 30, 2019, 10:21:04 pm@engkin ... it is something with "create file" even this raises the same error: (typed off the top of my head, but using old Pascal syntax same error): Assign(BFH,'testing.456'); Rewrite(BFH,1); <--- Access Violation Close(BFH); Again the code works on Linux and Mac, hmmm. This post contradicts your first post: QuoteIf I change code to use Assign(File,'testing.123'); Rewrite(File,1); etc. works on Windows. My guess: it works, you open the file 'testing.123' or 'testing.456' with some application to check the contents and it blocks access to it, maybe? ---------------------------------------------------------------------- Cyrax · 2019-01-30 23:43 Quote from: ozznixon on January 30, 2019, 10:21:04 pm@engkin ... it is something with "create file" even this raises the same error: (typed off the top of my head, but using old Pascal syntax same error): Assign(BFH,'testing.456'); Rewrite(BFH,1); <--- Access Violation Close(BFH); Again the code works on Linux and Mac, hmmm. In under what directory structure you are saving your project files? Please check security permission settings of your directories.