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. Error C2664: 'GetVolumeInformationW' : cannot convert parameter 1 from 'const char [4]' to 'LPCWSTR'

Error C2664: 'GetVolumeInformationW' : cannot convert parameter 1 from 'const char [4]' to 'LPCWSTR'

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studioquestion
12 Posts 5 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.
  • J Offline
    J Offline
    J_E_D_I
    wrote on last edited by
    #1

    Hi, I've written a program in c++ (using DLL) which uses the function below to show the HDD Serial No (as assigned by Windows). The program works fine in DLL mode but when I try to convert it into a Static Library Visual Studio 205 returns this error. Could anybody help please? Many thanks // Gets HDD serial No char volumeName[MAX_PATH]; DWORD volumeSerialNumber; DWORD maxNameLength; DWORD fileSystemFlags; char systemName[MAX_PATH]; // get the volume information for drive C GetHDDserialNo = GetVolumeInformation("c:\\", volumeName, MAX_PATH, &volumeSerialNumber, &maxNameLength, &fileSystemFlags, systemName, MAX_PATH);

    R 1 Reply Last reply
    0
    • J J_E_D_I

      Hi, I've written a program in c++ (using DLL) which uses the function below to show the HDD Serial No (as assigned by Windows). The program works fine in DLL mode but when I try to convert it into a Static Library Visual Studio 205 returns this error. Could anybody help please? Many thanks // Gets HDD serial No char volumeName[MAX_PATH]; DWORD volumeSerialNumber; DWORD maxNameLength; DWORD fileSystemFlags; char systemName[MAX_PATH]; // get the volume information for drive C GetHDDserialNo = GetVolumeInformation("c:\\", volumeName, MAX_PATH, &volumeSerialNumber, &maxNameLength, &fileSystemFlags, systemName, MAX_PATH);

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      Try this code:

      TCHAR volumeName\[MAX\_PATH\];
      DWORD volumeSerialNumber;
      DWORD maxNameLength;
      DWORD fileSystemFlags;
      TCHAR systemName\[MAX\_PATH\];
      
      // get the volume information for drive C
      GetHDDserialNo = GetVolumeInformation(\_T("c:\\\\"),
      	volumeName, MAX\_PATH,
      	&volumeSerialNumber,
      	&maxNameLength,
      	&fileSystemFlags,
      	systemName, MAX\_PATH); 
      

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

      J 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Try this code:

        TCHAR volumeName\[MAX\_PATH\];
        DWORD volumeSerialNumber;
        DWORD maxNameLength;
        DWORD fileSystemFlags;
        TCHAR systemName\[MAX\_PATH\];
        
        // get the volume information for drive C
        GetHDDserialNo = GetVolumeInformation(\_T("c:\\\\"),
        	volumeName, MAX\_PATH,
        	&volumeSerialNumber,
        	&maxNameLength,
        	&fileSystemFlags,
        	systemName, MAX\_PATH); 
        

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        J Offline
        J Offline
        J_E_D_I
        wrote on last edited by
        #3

        An absolute Genius! Thank you so much. But why is that?

        C R 2 Replies Last reply
        0
        • J J_E_D_I

          An absolute Genius! Thank you so much. But why is that?

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          Because you have UNICODE enabled, so a lot of functions from the Win32 API expect strings in UNICODE and not in ANSI. I suggest you search for articles on that subject here on codeproject, it is a bit broad to explain in one single post.

          Cédric Moonen Software developer
          Charting control [v1.3]

          1 Reply Last reply
          0
          • J J_E_D_I

            An absolute Genius! Thank you so much. But why is that?

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Hontesly no genius. Trust me, it is a simple thing. Read on Generic text mappings.

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            CPalliniC J 2 Replies Last reply
            0
            • R Rajesh R Subramanian

              Hontesly no genius. Trust me, it is a simple thing. Read on Generic text mappings.

              Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Rajesh R Subramanian wrote:

              Hontesly no genius.

              Actually, you are a genius. Only geniuses swap not adjacent characters in a word the way you did. :laugh:

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              In testa che avete, signor di Ceprano?

              R 1 Reply Last reply
              0
              • CPalliniC CPallini

                Rajesh R Subramanian wrote:

                Hontesly no genius.

                Actually, you are a genius. Only geniuses swap not adjacent characters in a word the way you did. :laugh:

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                Yuo wlil nto msis oen signle cahnce to mcok at me, wlil oyu? :laugh:

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                CPalliniC 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Yuo wlil nto msis oen signle cahnce to mcok at me, wlil oyu? :laugh:

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Oh no, you reverted to common-man adjacent characters swapping! :sigh: :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  In testa che avete, signor di Ceprano?

                  R 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Oh no, you reverted to common-man adjacent characters swapping! :sigh: :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    Probably this[^] would give you an idea why such swapping happens while I type. :)

                    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                    1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      Hontesly no genius. Trust me, it is a simple thing. Read on Generic text mappings.

                      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                      J Offline
                      J Offline
                      J_E_D_I
                      wrote on last edited by
                      #10

                      Well, thanks to both of you for the explanations anyway. It solved the problem.

                      M 1 Reply Last reply
                      0
                      • J J_E_D_I

                        Well, thanks to both of you for the explanations anyway. It solved the problem.

                        M Offline
                        M Offline
                        Michael Dunn
                        wrote on last edited by
                        #11

                        Start here: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^]

                        --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze

                        J 1 Reply Last reply
                        0
                        • M Michael Dunn

                          Start here: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^]

                          --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze

                          J Offline
                          J Offline
                          J_E_D_I
                          wrote on last edited by
                          #12

                          Thanks!

                          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