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. casting problems for int

casting problems for int

Scheduled Pinned Locked Moved C / C++ / MFC
11 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.
  • R Offline
    R Offline
    roadragedave
    wrote on last edited by
    #1

    unsigned int it = V_INT(&PhysicalMemoryVal); Does this actually make sense here or is there some problems with the pointers We have a mathematician, a different kind of mathematician, and a statistician!

    V D 2 Replies Last reply
    0
    • R roadragedave

      unsigned int it = V_INT(&PhysicalMemoryVal); Does this actually make sense here or is there some problems with the pointers We have a mathematician, a different kind of mathematician, and a statistician!

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Interesting. What is PhysicalMemoryVal? Looks like you are casting its memory address, not what is occupied in memory. kuphryn

      R 1 Reply Last reply
      0
      • V valikac

        Interesting. What is PhysicalMemoryVal? Looks like you are casting its memory address, not what is occupied in memory. kuphryn

        R Offline
        R Offline
        roadragedave
        wrote on last edited by
        #3

        Thats what I tought, how do I get the proper value please???? Oh by the way PhysicalMemoryVal is the amount of memory the operating system has available, you get it from WMI classes We have a mathematician, a different kind of mathematician, and a statistician!

        V 1 Reply Last reply
        0
        • R roadragedave

          Thats what I tought, how do I get the proper value please???? Oh by the way PhysicalMemoryVal is the amount of memory the operating system has available, you get it from WMI classes We have a mathematician, a different kind of mathematician, and a statistician!

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #4

          Given that PhysicalMemoryVal is a memory address, one possible solution is pointer. unsigned int *pValue = PhysicalMemoryVal; Kuphryn

          R 2 Replies Last reply
          0
          • V valikac

            Given that PhysicalMemoryVal is a memory address, one possible solution is pointer. unsigned int *pValue = PhysicalMemoryVal; Kuphryn

            R Offline
            R Offline
            roadragedave
            wrote on last edited by
            #5

            no good, now I get and error error C2440: 'initializing' : cannot convert from 'INT' to 'unsigned int *' But I dont understand because I use another function in the same way only it return a 16 bit int and there seems to be no problem there We have a mathematician, a different kind of mathematician, and a statistician!

            1 Reply Last reply
            0
            • V valikac

              Given that PhysicalMemoryVal is a memory address, one possible solution is pointer. unsigned int *pValue = PhysicalMemoryVal; Kuphryn

              R Offline
              R Offline
              roadragedave
              wrote on last edited by
              #6

              Actually!!!! how do i declare a 64 bit int???????? uint64????? We have a mathematician, a different kind of mathematician, and a statistician!

              V D 2 Replies Last reply
              0
              • R roadragedave

                Actually!!!! how do i declare a 64 bit int???????? uint64????? We have a mathematician, a different kind of mathematician, and a statistician!

                V Offline
                V Offline
                valikac
                wrote on last edited by
                #7

                Check out MSDN. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows\_data\_types.asp Check out my website for more links on software development. http://www.dslextreme.com/users/kuphryn/links.html Kuphryn

                1 Reply Last reply
                0
                • R roadragedave

                  unsigned int it = V_INT(&PhysicalMemoryVal); Does this actually make sense here or is there some problems with the pointers We have a mathematician, a different kind of mathematician, and a statistician!

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  What type is PhysicalMemoryVal? Your code will only work if it is a VARIANT.


                  "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                  R 1 Reply Last reply
                  0
                  • R roadragedave

                    Actually!!!! how do i declare a 64 bit int???????? uint64????? We have a mathematician, a different kind of mathematician, and a statistician!

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    roadragedave wrote: how do i declare a 64 bit int???????? __int64


                    "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                    1 Reply Last reply
                    0
                    • D David Crow

                      What type is PhysicalMemoryVal? Your code will only work if it is a VARIANT.


                      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                      R Offline
                      R Offline
                      roadragedave
                      wrote on last edited by
                      #10

                      Yes PhysicalMemoryVal is a VARIANT The value returns something, but its a negative number which doesnt make any sense http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_operatingsystem.asp at this website you will find a uint64 FreePhysicalMemory Im trying to plot this against another value uint64 TotalVisableMemorySize but the values Im getting are way out My GetProperty method for getting the values works fine, because I have it fetching another value without any problems.

                      D 1 Reply Last reply
                      0
                      • R roadragedave

                        Yes PhysicalMemoryVal is a VARIANT The value returns something, but its a negative number which doesnt make any sense http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_operatingsystem.asp at this website you will find a uint64 FreePhysicalMemory Im trying to plot this against another value uint64 TotalVisableMemorySize but the values Im getting are way out My GetProperty method for getting the values works fine, because I have it fetching another value without any problems.

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        IWbemClassObject *pClass;
                        _variant_t v;
                        HRESULT hr;

                        hr = pClass->Get(L"FreePhysicalMemory", 0, &v, NULL, NULL);
                        if (SUCCEEDED(hr) && VT_NULL != v.vt)
                        TRACE("FreePhysicalMemory = %S KB\n", V_BSTR(&v));

                        hr = pClass->Get(L"TotalVisibleMemorySize", 0, &v, NULL, NULL);
                        if (VT_NULL != v.vt)
                        TRACE("TotalVisibleMemorySize = %S KB\n", V_BSTR(&v));


                        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                        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