neopolis
asked on
Create A File
Ok i want to create a file called win34.dll
the file has to go to C:\Windows\win34.dll
sample code is appreciated such as uses var etc i am new at delphi
thanks in advance
the file has to go to C:\Windows\win34.dll
sample code is appreciated such as uses var etc i am new at delphi
thanks in advance
If you want to create an empty file, then use :
FileClose(FileCreate(strFi leName));
If you want to create a new file and write data to it, use :
var
fAFile : TextFile;
strFileName : String;
strData : String;
AssignFile(fAFile, StrFileName); { Assign a FileName to the FilePointer }
Rewrite(fAFile); { Create the file and open it }
Writeln(fAFile, strData); { Write data to the file. }
Flush(fAFile); { to be sure the data is written. }
CloseFile(fAFile); { Close the file file }
FileClose(FileCreate(strFi
If you want to create a new file and write data to it, use :
var
fAFile : TextFile;
strFileName : String;
strData : String;
AssignFile(fAFile, StrFileName); { Assign a FileName to the FilePointer }
Rewrite(fAFile); { Create the file and open it }
Writeln(fAFile, strData); { Write data to the file. }
Flush(fAFile); { to be sure the data is written. }
CloseFile(fAFile); { Close the file file }
If you want to save a textfile with a dll extention then try this:
Just put a Memo and a button on your form. Then doubleclick on the button and insert this code:
Memo1.Lines.SaveToFile('C: \Windows\w in34.dll') ;
Now you just start you program (F9).
If you press the button everything what you write in the memofield will be saved in C:\Windows\win34.dll
Hope I could help
:)dluedi
Just put a Memo and a button on your form. Then doubleclick on the button and insert this code:
Memo1.Lines.SaveToFile('C:
Now you just start you program (F9).
If you press the button everything what you write in the memofield will be saved in C:\Windows\win34.dll
Hope I could help
:)dluedi
ASKER
ok it just a blank file i want to create, No text just create the file with the dll extension
i tried this FileClose(FileCreate(strFi leName));
but where do i put the Path and File name
and is there any var etc to put..
thanks
i tried this FileClose(FileCreate(strFi
but where do i put the Path and File name
and is there any var etc to put..
thanks
ASKER
i asked the question again but i explain more in detail this time, the help is good but i need to explain myself better sorry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hello neopolis, To create and empty file with windows API use the CreateFile()
var
hFile1: HWND;
FileName: String;
FileName := "C:\Folder\File1.dll";
hFile1 := CreateFile(PChar(FileName) , GENERIC_WRITE, FILE_SHARE_READ, nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_SEQUENTIAL_SCAN, 0);
CloseHandle(hFile1);
var
hFile1: HWND;
FileName: String;
FileName := "C:\Folder\File1.dll";
hFile1 := CreateFile(PChar(FileName)
CloseHandle(hFile1);
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
accept wimmeyvaert's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thanks,
geobul
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
accept wimmeyvaert's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thanks,
geobul
EE Cleanup Volunteer
Hi Geobul,
Thanks for evaluating this question. Hope there will be a reaction from 'neopolis'.
Best regards,
The Mayor.
Thanks for evaluating this question. Hope there will be a reaction from 'neopolis'.
Best regards,
The Mayor.
Thanks for the accaptance, neopolis !!
The Mayor