Solved

Create A File

Posted on 2001-08-22
10
295 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:neopolis
10 Comments
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6412880
Do you really want to create a DLL, or is this just an example, and is it a textfile you want to create.

The Mayor
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6412893
If you want to create an empty file, then use :
    FileClose(FileCreate(strFileName));

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 }
0
 
LVL 1

Expert Comment

by:dluedi
ID: 6412898
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\win34.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
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:neopolis
ID: 6413339
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(strFileName));

but where do i put the Path and File name
and is there any var etc to put..
thanks
0
 

Author Comment

by:neopolis
ID: 6414555
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
0
 
LVL 6

Accepted Solution

by:
wimmeyvaert earned 10 total points
ID: 6416471
strFileName = Path + Filename

Example :
FileClose(FileCreate('C:\WinNt\System32\MyDll.Dll'));

Best regards,
The Mayor

0
 
LVL 33

Expert Comment

by:Slick812
ID: 6430713
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);
0
 
LVL 17

Expert Comment

by:geobul
ID: 9287801
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
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 9307588
Hi Geobul,

Thanks for evaluating this question. Hope there will be a reaction from 'neopolis'.
Best regards,

The Mayor.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 9368586
Thanks for the accaptance, neopolis !!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to renew a Delphi rad-studio licence? 5 64
Find and Replace Stream with 0s 8 62
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 34
RESTRequest Parameter 4 30
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question