Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

copy file over a network

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abubakar - 24 Oct 2005 08:44 GMT
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$\\sample2.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.
William DePalo [MVP VC++] - 24 Oct 2005 15:27 GMT
> BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\sample2.txt"),
> FALSE );
[quoted text clipped - 3 lines]
> 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
Abubakar - 25 Oct 2005 09:28 GMT
Thanks for reply. Its very helpful.

-Ab.

> > BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\sample2.txt"),
> > FALSE );
[quoted text clipped - 17 lines]
> Regards,
> Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.