The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Copy files from SMB using Win32
Discuss Copy files from SMB using Win32 in the C Programming forum on Dev Shed. Copy files from SMB using Win32 C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 7th, 2013, 11:16 AM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
Copy files from SMB using Win32
HI, I'm trying to copy files from "\\ip\folder\file.txt" to "c:\file.txt".
The server asks for username/ password when I enter the \\ip in Windows XP "Run" or start-menu search in vista/7.
I do not want to use any high-level APIs, not even from MS. I want to keep it to the lowest abstraction level possible at Win32 API.
Sincerely,
speedbooster
|

January 7th, 2013, 02:44 PM
|
 |
I'm Baaaaaaack!
|
|
Join Date: Jul 2003
Location: Maryland
|
|
|
If you are copying from a network drive, as appears to be the case, then you will have to be authenticated which means you have to work through APIs (unless you want to attempt to recreate teh arcane crypto framework used to talk to the remote drive), almost certainly OS dependent APIs (meaning even if they are third-party, they are running in kernel space). I would be suprised if you get much help here, we tend to focus on ANSI programming. Also, for all practical purposes, what you are asking is language independent. Devshed should have some forums better suited for your question.
|

January 7th, 2013, 02:57 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
thanks,  perhaps im asking about windows programming?
anyways, i have opened the connection and mapped the network share with correct login to z: drive. I need to copy files now. Looking for function. i don't want to use system()
|

January 8th, 2013, 10:28 AM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|
who the heck's void pointer?!
I know what I am talking about over here !! I'm an old member, though not much active.
|

January 8th, 2013, 10:31 AM
|
 |
I'm Baaaaaaack!
|
|
Join Date: Jul 2003
Location: Maryland
|
|
|
Right, so you should realize that he is commenting on Nancy's useless post.
|

January 8th, 2013, 10:39 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Quote: | Originally Posted by speedbooster thanks,  perhaps im asking about windows programming?
anyways, i have opened the connection and mapped the network share with correct login to z: drive. I need to copy files now. Looking for function. i don't want to use system() |
Use CopyFile() or CopyFileEx() perhaps.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

January 8th, 2013, 12:27 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|
Oh, thanks mitakeet.
@scorpion4ever, yeah i m doing that now. thanks a lot : )
|

January 8th, 2013, 12:32 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|
i have a question actually. When i open \\ip in the start menu or 'run' in xp, it doesn't 'map' the network path to a drive, but i can still use it. explorer shows '\\ip\path\to\directory\whatever\' in address bar.
'net use' command also shows a 'connection??'
How come I'm using the resource without mapping?
Is it possible to do with win32 as well? Like with CopyFile ? With CopyFile(), I am currently 'mapping' the path to a drive and then copying. But I'd like something like I've mentioned to be done in my C++ program.
|

January 8th, 2013, 02:30 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
If you look at the docs, it says that CopyFile() can also accept "\\ip\path\to\directory\whatever\" type strings.
|

January 10th, 2013, 11:24 AM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
hmmm, i think it was returning 66 or 85 error. Perhaps i need to kill all SMB connections with net command ....
Anyways, I got another problem. I'm trying to launch Internet explorer and open a page in it. Its working, but the ExecWB function in IWebBrowser2 is giving access violations.
Code:
Unhandled exception at 0x7338C9F1 in file.exe: 0xC0000005: Access violation executing location: 0x00000000
It goes away if I remove the line. The line is:
Code:
pWBApp->ExecWB(OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
// i also tried
pWBApp->ExecWB(OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
Reference: http://msdn.microsoft.com/en-us/lib...v=vs.85%29.aspx
|

January 10th, 2013, 11:55 AM
|
 |
Contributed User
|
|
|
|
> Access violation executing location: 0x00000000
You tried to call NULL!
> pWBApp->ExecWB(OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
It would seem that the ExecWB member is not set up at all.
> It goes away if I remove the line.
Actually, I would recommend you get familiar with using the debugger.
Find out where ExecWB "should" have been initialised, and put a breakpoint on it. Investigate WHY it isn't being set up - did you miss an init call somewhere - read the documentation.
Random hacking of adding and commenting out lines of code is voodoo programming
> hmmm, i think it was returning 66 or 85 error.
Don't think - KNOW!
Trust me, you'll find yourself rapidly shunned if we spend effort looking into those two values, and you show up tomorrow saying "sorry, my bad - it was 42".
|

January 10th, 2013, 12:57 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|

January 10th, 2013, 01:37 PM
|
 |
Contributed User
|
|
|
|
I'm confused....
Quote:
I do not want to use any high-level APIs, not even from MS. I want to keep it to the lowest abstraction level possible at Win32 API. |
IWebBrowser2 et al seem anything but the lowest level API's.
> you think i didn't read the docs before asking?
You'd be surprised how often it turns out to be true.
Kudos to you for being exceptional.
|

January 10th, 2013, 01:44 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|
thanks, well.... the lowest i could compromise was the IWB2 interface.... I would've gone to TCP/IP but the firewall pop-ups are unreasonable.
btw, im lazy when it comes to creating new posts. I could search for hours on google, but creating a 'New Thread' is usually a hassle for me : D
So, any idea on the problem? One guy on MSDN forum suggests pWBApp is NULL, I tried
> if (pWBApp == nullptr)
and it returns false.
and i did add breakpoints, although there's little point of it because there is nothing like 'initializing' the ExecWB()
Last edited by speedbooster : January 10th, 2013 at 01:46 PM.
|

January 10th, 2013, 01:49 PM
|
|
Contributing User
|
|
Join Date: Jun 2005
Posts: 220
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
|
|
|
i was wondering, is there any way to evaluate a method for nullity?
> if (pWBApp->ExecWB())
won't compile, asking for arguments. If I put in the arguments, its the same story.....
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|