Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Database Create Date

Status
Not open for further replies.

timb94

Programmer
Apr 20, 2004
58
US
I've done a search and couldn't come up with an answer so I'm not sure if this can be done or not.

I have to copy a database (.mdb) from a server directory to a local harddrive.

I'm using the CopyFile command from Scripting.FileSystemObject to copy the database and this works fine. No problems.

Now I'm told the creation date of the destination database has to be the same as the source. In using the above the creation date for the destination is always the current date.

I can extract the creation date from the source with .DateCreated but is there a way to replace the destination date created?

Any assistance would be appreciated.
 
timb94,
Change a File's Last Modified Date Stamp

The key is
[tt]Private Declare Function SetFileTime Lib "kernel32" _
(ByVal hFile As Long, ByVal MullP As Long, _
ByVal NullP2 As Long, lpLastWriteTime _
As FILETIME) As Long[/tt]
and I believe:[ul]
[li][tt]MullP[/tt] = creation time[/li]
[li][tt]NullP2[/tt] = Last Accessed Time[/li]
[li][tt]lpLastWriteTime[/tt] = last moddified time.[/li][/ul]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thank you CautionMP for the reply.

However I have not worked with the kernel32 very much and I have a couple of questions in trying to understand the function.

1.
Is the variable hFile for the file name? If so why is it declared as a Long data type? Do I need to pass it a file path?

2.
If I only need to modify the creation date do I still have to declare the last access and modified times and pass these to the function?



 
timb94,
Ditto on the [tt]kernel32[/tt] API's, I know just enough to dangerous. To answer your questions:
[ol][li]No, [tt]hFile[/tt] is the handle to the file so it needs to be a long data type. The handle is returned when the file name is passed to [tt]CreateFile()[/tt][/li]
[li]Yes, if you don't the API will most likely throw an error.[/li][/ol]

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top