nt vs. 9x api call?

nt vs. 9x api call?

Anonymous
Not applicable
308 Views
5 Replies
Message 1 of 6

nt vs. 9x api call?

Anonymous
Not applicable
Does anyone know the call to copyfile in 95/98?
In nt I'm using:
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal
lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
bFailIfExists As Long) As Long

but in 95 and 98 I get "run time error 75 .... path/file access error"
Is the library user32? Different alias?
-Josh
0 Likes
309 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Hiya,

Not sure the exact declare for copyfile in 95/98 but why do you need to use the API to copy a file? Just use FileCopy...

Wish I could help ya more on this but I dont have any 98 machines to fiddle with. Randall Rath will know this one though... Randall?

Micah
0 Likes
Message 3 of 6

Anonymous
Not applicable
Here is the description from the MSDN CD.

CopyFile
The CopyFile function copies an existing file to a new file.

The CopyFileEx function provides two additional capabilities.
CopyFileEx can call a specified callback function each time a
portion of the copy operation is completed, and CopyFileEx can be
canceled during the copy operation.

BOOL CopyFile(
LPCTSTR lpExistingFileName, // name of an existing file
LPCTSTR lpNewFileName, // name of new file
BOOL bFailIfExists // operation if file exists
);
Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that specifies the name of
an existing file.
Windows NT/2000: In the ANSI version of this function, the name is
limited to MAX_PATH characters. To extend this limit to nearly
32,000 wide characters, call the Unicode version of the function and
prepend "\\?\" to the path. For more information, see File Name
Conventions.

Windows 95/98: This string must not exceed MAX_PATH characters.

lpNewFileName
[in] Pointer to a null-terminated string that specifies the name of
the new file.
Windows NT/2000: In the ANSI version of this function, the name is
limited to MAX_PATH characters. To extend this limit to nearly
32,000 wide characters, call the Unicode version of the function and
prepend "\\?\" to the path. For more information, see File Name
Conventions.

Windows 95/98: This string must not exceed MAX_PATH characters.

bFailIfExists
[in] Specifies how this operation is to proceed if a file of the
same name as that specified by lpNewFileName already exists. If this
parameter is TRUE and the new file already exists, the function
fails. If this parameter is FALSE and the new file already exists,
the function overwrites the existing file and succeeds.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended
error information, call GetLastError.

Remarks
Security attributes for the existing file are not copied to the new
file.

File attributes for the existing file are copied to the new file.
For example, if an existing file has the FILE_ATTRIBUTE_READONLY
file attribute, a copy created through a call to CopyFile will also
have the FILE_ATTRIBUTE_READONLY file attribute.

MAPI: For more information, see Syntax and Limitations for Win32
Functions Useful in MAPI Development.

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows
NT/2000.

See Also
File I/O Overview, File I/O Functions, CopyFileEx, CreateFile,
MoveFile

Minkwitz Design wrote in message
news:390778D8.724F4D26@xta.com...
> Does anyone know the call to copyfile in 95/98?
> In nt I'm using:
> Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA"
(ByVal
> lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
> bFailIfExists As Long) As Long
>
> but in 95 and 98 I get "run time error 75 .... path/file access
error"
> Is the library user32? Different alias?
> -Josh
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi Micah,
Thanks for the advice, but there is a difference. I actually tried FileCopy first. The FileCopy command will error out if the file
being copied is open, whereas the copyfile call acts like copy and paste in explorer and doesn't care if the file is open or not. It
simply copies whatever was last saved. Which is exactly what I'm looking for since the file being copied will always be open when my
macro is executed.
-Josh

mnerren wrote:

> Hiya,
>
> Not sure the exact declare for copyfile in 95/98 but why do you need to use the API to copy a file? Just use FileCopy...
>
> Wish I could help ya more on this but I dont have any 98 machines to fiddle with. Randall Rath will know this one though... Randall?
>
> Micah
0 Likes
Message 5 of 6

Anonymous
Not applicable
I have also found that the API runs much faster than FileCopy.

- Adam

"Minkwitz Design" wrote in message
news:390851FA.BA4358A9@xta.com...
> Hi Micah,
> Thanks for the advice, but there is a difference. I actually tried
FileCopy first. The FileCopy command will error out if the file
> being copied is open, whereas the copyfile call acts like copy and paste
in explorer and doesn't care if the file is open or not. It
> simply copies whatever was last saved. Which is exactly what I'm looking
for since the file being copied will always be open when my
> macro is executed.
> -Josh
>
> mnerren wrote:
>
> > Hiya,
> >
> > Not sure the exact declare for copyfile in 95/98 but why do you need to
use the API to copy a file? Just use FileCopy...
> >
> > Wish I could help ya more on this but I dont have any 98 machines to
fiddle with. Randall Rath will know this one though... Randall?
> >
> > Micah
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thanks Tom,
This clip was helpful. I'm a step closer to finding my problem.
-Josh
0 Likes