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. Cant we develope a dll which can be work in both vista and XP?

Cant we develope a dll which can be work in both vista and XP?

Scheduled Pinned Locked Moved C / C++ / MFC
workspacevisual-studiodata-structuresbusinesstutorial
3 Posts 2 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.
  • W Offline
    W Offline
    WindowsPistha
    wrote on last edited by
    #1

    Hi All, We have one dll which can be used in many Exes and different Operating systems. At present i am having one requirement to support to get the LocalLow path in vista. So I have implemented separate function for it. I have used SHGetKnownFolderPath funciton to get the LocalLow path. To compile the workspace , I have to use WINVER value as 0x0600. IF we defined the WinVersion as 6 , DLL is not running in XP. Developement Environment :VS 2005 & Vista Business. //In Vista Expected output : C:\Users\bob\AppData\LocalLow\eGrabber\ //In XP Expceted output: C:\Documents and Settings\Smith\Application Data\eGrabber\ int GetCurrentUserLocalLowAppPath(LPTSTR szProfileDir,int dirlen ) { memset(szProfileDir,0,dirlen); if(IsWinXP() == TRUE) { GetCurrentUserAppPath( szProfileDir, dirlen ); } else if(IsVista() == TRUE) { PWSTR pszPath[1]; SHGetKnownFolderPath(NULL,FOLDERID_LocalAppDataLow,0,NULL,pszPath); //copying the pszPath to szProfileDir array } return 1; } Any idea how to achieve this. Your suggestion welcomed ... Thanks.

    N 1 Reply Last reply
    0
    • W WindowsPistha

      Hi All, We have one dll which can be used in many Exes and different Operating systems. At present i am having one requirement to support to get the LocalLow path in vista. So I have implemented separate function for it. I have used SHGetKnownFolderPath funciton to get the LocalLow path. To compile the workspace , I have to use WINVER value as 0x0600. IF we defined the WinVersion as 6 , DLL is not running in XP. Developement Environment :VS 2005 & Vista Business. //In Vista Expected output : C:\Users\bob\AppData\LocalLow\eGrabber\ //In XP Expceted output: C:\Documents and Settings\Smith\Application Data\eGrabber\ int GetCurrentUserLocalLowAppPath(LPTSTR szProfileDir,int dirlen ) { memset(szProfileDir,0,dirlen); if(IsWinXP() == TRUE) { GetCurrentUserAppPath( szProfileDir, dirlen ); } else if(IsVista() == TRUE) { PWSTR pszPath[1]; SHGetKnownFolderPath(NULL,FOLDERID_LocalAppDataLow,0,NULL,pszPath); //copying the pszPath to szProfileDir array } return 1; } Any idea how to achieve this. Your suggestion welcomed ... Thanks.

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      The only problem for not working the dll in windows XP is that, it is using a function(SHGetKnownFolderPath), that is not available in windows XP. To solve this problem, instead of statically linking to the SHGetKnownFolderPath() function, dynamically call it. That is, using the LoadLibrary() and GetProcAddress() functions.

      nave [OpenedFileFinder] [My Blog]

      W 1 Reply Last reply
      0
      • N Naveen

        The only problem for not working the dll in windows XP is that, it is using a function(SHGetKnownFolderPath), that is not available in windows XP. To solve this problem, instead of statically linking to the SHGetKnownFolderPath() function, dynamically call it. That is, using the LoadLibrary() and GetProcAddress() functions.

        nave [OpenedFileFinder] [My Blog]

        W Offline
        W Offline
        WindowsPistha
        wrote on last edited by
        #3

        Thanks Naveen. Here is the code for it.

        typedef HRESULT (WINAPI * SHGetKnownFolderPathFn)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken,PWSTR *ppszPath);

        PWSTR pszPath\[1\];
        SHGetKnownFolderPathFn shGetKnownFolrPth = NULL ;
        
            HINSTANCE hins = LoadLibrary("Shell32.dll");
        

        if(hins != NULL)
        {

        shGetKnownFolrPth = (SHGetKnownFolderPathFn)::GetProcAddress(hins,"SHGetKnownFolderPath");

         if( shGetKnownFolrPth != NULL) 
        		 {
        		 shGetKnownFolrPth(FOLDERID\_LocalAppDataLow,0,NULL,pszPath);
        		 CString csData=pszPath\[0\]; // converting from wchar to ANSI.
        		}
        }
        
        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