C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 7th, 2013, 11:16 AM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
Exclamation 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

Reply With Quote
  #2  
Old January 7th, 2013, 02:44 PM
mitakeet's Avatar
mitakeet mitakeet is offline
I'm Baaaaaaack!
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 5,538 mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 38 m 46 sec
Reputation Power: 242
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.
__________________

My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
  #3  
Old January 7th, 2013, 02:57 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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()

Reply With Quote
  #4  
Old January 8th, 2013, 10:28 AM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #5  
Old January 8th, 2013, 10:31 AM
mitakeet's Avatar
mitakeet mitakeet is offline
I'm Baaaaaaack!
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 5,538 mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 38 m 46 sec
Reputation Power: 242
Right, so you should realize that he is commenting on Nancy's useless post.

Reply With Quote
  #6  
Old January 8th, 2013, 10:39 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,406 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 9 h 35 m 45 sec
Reputation Power: 4080
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

Reply With Quote
  #7  
Old January 8th, 2013, 12:27 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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 : )

Reply With Quote
  #8  
Old January 8th, 2013, 12:32 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #9  
Old January 8th, 2013, 02:30 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,406 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 9 h 35 m 45 sec
Reputation Power: 4080
If you look at the docs, it says that CopyFile() can also accept "\\ip\path\to\directory\whatever\" type strings.

Reply With Quote
  #10  
Old January 10th, 2013, 11:24 AM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #11  
Old January 10th, 2013, 11:55 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,905 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 4 Days 1 h 2 m 3 sec
Reputation Power: 1774
> 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".
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #12  
Old January 10th, 2013, 12:57 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 6 h 22 m 31 sec
Reputation Power: 0
i was getting both 66 and 85, trying different things. But i got it to work anyhow.

you think i didn't read the docs before asking? Here is the 'extensive' documentation from MS:

http://msdn.microsoft.com/en-us/lib...v=vs.85%29.aspx

Reply With Quote
  #13  
Old January 10th, 2013, 01:37 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,905 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 4 Days 1 h 2 m 3 sec
Reputation Power: 1774
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.

Reply With Quote
  #14  
Old January 10th, 2013, 01:44 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #15  
Old January 10th, 2013, 01:49 PM
speedbooster speedbooster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 220 speedbooster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.....

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Copy files from SMB using Win32

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap