473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

copy file over a network

Hi,
I'm using pure win32 (no atl or mfc) to copy files from my pc to other pc.
Currently I'm administrator of the other person's pc so my copy of file is
successful without a problem by using following code:

BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\samp le2.txt"),
FALSE );

This works fine. Now my concern is that if I'm not an admin of the other
guy's pc, it'll require username and password for my code to copying file.
In that case how will I specify the username and password? What apis are
used for that?

many thanks,

Ab.
Nov 17 '05 #1
2 947
"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\samp le2.txt"),
FALSE );

This works fine. Now my concern is that if I'm not an admin of the other
guy's pc, it'll require username and password for my code to copying file.
In that case how will I specify the username and password? What apis are
used for that?


LogonUser(); // gets you a handle to a token

ImpersonateLoggedOnUser(); // "changes" security context

CopyFile(); // copies file under changed context

RevertToSelf(); // switches back to normal

Prior to XP you will need the SE_TCB_NAME ("act as part of the operating
system") privilege.

Regards,
Will

Nov 17 '05 #2
Thanks for reply. Its very helpful.

-Ab.
"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message
news:uK**************@TK2MSFTNGP15.phx.gbl...
"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\samp le2.txt"),
FALSE );

This works fine. Now my concern is that if I'm not an admin of the other
guy's pc, it'll require username and password for my code to copying file. In that case how will I specify the username and password? What apis are
used for that?


LogonUser(); // gets you a handle to a token

ImpersonateLoggedOnUser(); // "changes" security context

CopyFile(); // copies file under changed context

RevertToSelf(); // switches back to normal

Prior to XP you will need the SE_TCB_NAME ("act as part of the operating
system") privilege.

Regards,
Will

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Finch | last post by:
We are running SQL 7 on a Windows NT Server. If you copy a 25Mb file from this machine to a W2K server, the file copy takes over 5 minutes on a 100Mpbs switched network. Copying the same file to...
2
by: Paul | last post by:
Dear All, I want to use web form to upload my file and copy the file to another machine. I can upload the file, but when I copy the file(file.CopyTo(".....", true)) to another machine(map...
8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
4
by: adnan boz | last post by:
Hi All, Does somebody know why File.Copy function is 10 times slower than standard windows drag and drop copy between folders, when I copy files over the network? Actually, I need to copy files...
0
by: Paul Brady | last post by:
I volunteer at a youth ministry agency and help them with their student database. They have two computers, both running Windows XP. Both have Office 2002 installed without Access, except that...
4
by: remya1000 | last post by:
i'm using VB.NET i have 4 computers in network. when i press a button i need to delete a table from computer 2,3,4 and i need to copy that table from computer 1 to 2,3,4. and this file is a...
25
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
1
by: =?Utf-8?B?UmFkZW5rb19aZWM=?= | last post by:
I am using standard File.Copy(source,dest,true) method in C# and I have problem with copying large number of files. Here is my code: foreach (FileInfo file in files) {...
1
by: Coni | last post by:
Hello, I am following steps to implement security on access 2003 through distribution: I have split the database and I am trying to distribute it: I have copied the back end file and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.