#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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()
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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.
  8. #5
  9. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    Right, so you should realize that he is commenting on Nancy's useless post.

    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
  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    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

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep Power
    0
    Oh, thanks mitakeet.
    @scorpion4ever, yeah i m doing that now. thanks a lot : )
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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.
  16. #9
  17. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    If you look at the docs, it says that CopyFile() can also accept "\\ip\path\to\directory\whatever\" type strings.
    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

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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/libr...=vs.85%29.aspx
  20. #11
  21. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    > 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
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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/libr...=vs.85%29.aspx
  24. #13
  25. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    I'm confused....
    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.
    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
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep 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.....

IMN logo majestic logo threadwatch logo seochat tools logo