Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. The SHCreateDirectoryEx function.

The SHCreateDirectoryEx function.

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iMikki
    wrote on last edited by
    #1

    Hi guys, Here I am again... But now with another problem :p SHCreateDirectoryEx(NULL, "c:\\text", NULL); gives me the following error:

    1>d:\app2\app2\Form1.h(302) : error C2664: 'SHCreateDirectoryExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    I found that _T("..") should work; giving me the following error:

    1>App2.obj : error LNK2028: unresolved token (0A000028) "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>App2.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>D:\App2\Debug\App2.exe : fatal error LNK1120: 2 unresolved externals

    Does anyone have experience with this function. I want to make a (n absolute) folder and the OS where this will be written for is Vista (sorry - I might upgrade to W7 tho). Could someone give me some hints? Kind regards,

    _ 1 Reply Last reply
    0
    • I iMikki

      Hi guys, Here I am again... But now with another problem :p SHCreateDirectoryEx(NULL, "c:\\text", NULL); gives me the following error:

      1>d:\app2\app2\Form1.h(302) : error C2664: 'SHCreateDirectoryExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
      1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

      I found that _T("..") should work; giving me the following error:

      1>App2.obj : error LNK2028: unresolved token (0A000028) "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
      1>App2.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
      1>D:\App2\Debug\App2.exe : fatal error LNK1120: 2 unresolved externals

      Does anyone have experience with this function. I want to make a (n absolute) folder and the OS where this will be written for is Vista (sorry - I might upgrade to W7 tho). Could someone give me some hints? Kind regards,

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Try referencing shell32.lib in Additional Dependencies option of the project Linker properties. If you're doing a C++/CLI application, you should be using Directory::CreateDirectory instead.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      I 1 Reply Last reply
      0
      • _ _Superman_

        Try referencing shell32.lib in Additional Dependencies option of the project Linker properties. If you're doing a C++/CLI application, you should be using Directory::CreateDirectory instead.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        I Offline
        I Offline
        iMikki
        wrote on last edited by
        #3

        I got an application. So called Windows Forms Application. I will try Directory::CreateDirectory. Thanks again. ---------- Edit: The IDE (Visual C++ Studio 2008 Express) cannot find Directory::CreateDirectory. I might to include some file I guess... ---------- Re-edit: CreateDirectory("c:\test", NULL); works... Sort of - now I get the following error:

        1>d:\app2\app2\Form1.h(304) : error C2664: 'CreateDirectory' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR'
        1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

        modified on Friday, November 13, 2009 1:06 PM

        _ 2 Replies Last reply
        0
        • I iMikki

          I got an application. So called Windows Forms Application. I will try Directory::CreateDirectory. Thanks again. ---------- Edit: The IDE (Visual C++ Studio 2008 Express) cannot find Directory::CreateDirectory. I might to include some file I guess... ---------- Re-edit: CreateDirectory("c:\test", NULL); works... Sort of - now I get the following error:

          1>d:\app2\app2\Form1.h(304) : error C2664: 'CreateDirectory' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR'
          1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

          modified on Friday, November 13, 2009 1:06 PM

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          You need to tell me if it is a managed or unmanaged application. Do you see using namespace xxx or #include xxx on the top of the file? And what are they?

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          I 1 Reply Last reply
          0
          • _ _Superman_

            You need to tell me if it is a managed or unmanaged application. Do you see using namespace xxx or #include xxx on the top of the file? And what are they?

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            I Offline
            I Offline
            iMikki
            wrote on last edited by
            #5

            Plentyyyyyy lol

            #pragma once
            #include <iostream>
            #include <fstream>
            #include <vector>
            #include <string>
            #include <algorithm>
            #include "Serial/Serial.cpp" //http://www.codeproject.com/KB/system/serial.aspx
            #include "shlobj.h"

            namespace App2 {
            using namespace std;
            using namespace System;
            using namespace System::ComponentModel;
            using namespace System::Collections;
            using namespace System::Windows::Forms;
            using namespace System::Data;
            using namespace System::Drawing;
            using namespace System::Runtime::InteropServices;

            1 Reply Last reply
            0
            • I iMikki

              I got an application. So called Windows Forms Application. I will try Directory::CreateDirectory. Thanks again. ---------- Edit: The IDE (Visual C++ Studio 2008 Express) cannot find Directory::CreateDirectory. I might to include some file I guess... ---------- Re-edit: CreateDirectory("c:\test", NULL); works... Sort of - now I get the following error:

              1>d:\app2\app2\Form1.h(304) : error C2664: 'CreateDirectory' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR'
              1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

              modified on Friday, November 13, 2009 1:06 PM

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              CreateDirectory(_T("c:\\test"), NULL);

              «_Superman_» I love work. It gives me something to do between weekends.
              Microsoft MVP (Visual C++)

              I 1 Reply Last reply
              0
              • _ _Superman_

                CreateDirectory(_T("c:\\test"), NULL);

                «_Superman_» I love work. It gives me something to do between weekends.
                Microsoft MVP (Visual C++)

                I Offline
                I Offline
                iMikki
                wrote on last edited by
                #7

                That works tho! :-O Thanks dude!

                P 1 Reply Last reply
                0
                • I iMikki

                  That works tho! :-O Thanks dude!

                  P Offline
                  P Offline
                  Patcher32
                  wrote on last edited by
                  #8

                  #include <shlobj.h>
                  int main(){
                  SHCreateDirectoryEx(NULL,"c:\\jinx",NULL);
                  return 0;
                  }

                  tested it with ms vc++ 2008. it works like charm :)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups