<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sorry to kick the topic, but in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816988#M45742</link>
    <description>&lt;P&gt;Sorry to kick the topic, but I encountered the same issue where the above code wouldn't work. After some tinkering and combining several posts on the internet, I got it working. Here's my code (works in IVF 11)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;#define MAX_PATH 260+1      

subroutine GetVersionInfoStrings(FILEVERSION)
	use IFWIN
	implicit none

	character(len=*), intent(out) :: FILEVERSION

	integer(4)         Hndl
	integer(4)         nBytes
	integer(4)         rc
	character(len=256) StringInfo

	integer(4)         uVersionLen
	integer(4)         lpstrVffInfo
	character(100)     lpVersion
	integer(4)         hMem
	integer(4)         i

	character(MAX_PATH) szFilename

	pointer(lplpVersion, lpversion)


	rc = GetModuleFileName(NULL, szFilename, MAX_PATH)
	nBytes = GetFileVersionInfoSize(szFilename, LOC(Hndl))

	if (nBytes /= 0) then
		hMem = GlobalAlloc(GMEM_MOVEABLE, int(nBytes))
		lpstrVffInfo = GlobalLock(hMem)
		rc = GetFileVersionInfo(szFilename, Hndl, nBytes, lpstrVffInfo )

		StringInfo = "\\StringFileInfo\\040904b0\\FileVersion"C  !hex 040904b0 is the code page set in the resource file
		rc = VerQueryValue(lpstrVffInfo, loc(StringInfo), lplpVersion, loc(uVersionLen))
		if (rc /= 0) then
			rc = lstrcpy(FILEVERSION, lpVersion)
			uVersionLen = min(uVersionLen,index(FILEVERSION,char(0)))
			do i=uVersionLen,len(FILEVERSION)
				FILEVERSION(i:i) = ' '
			end do
		else
			FILEVERSION = 'n.c'
		end if
 
		rc = GlobalUnlock(hMem)
		rc = GlobalFree(hMem)
	else
		FILEVERSION = 'n.c'
	end if
end&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Oct 2014 06:56:07 GMT</pubDate>
    <dc:creator>Michiel_Tukker</dc:creator>
    <dc:date>2014-10-10T06:56:07Z</dc:date>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816982#M45736</link>
      <description>I'm trying to access version information about my fortran program in code (for output printing and so forth). Presently that information is stored in a resource file (Version.rc) in my Visual Studio project file (*.vfproj). &lt;BR /&gt;&lt;BR /&gt;Is it possible to access the information in the resource file from code? If so, are there any example of doing this?</description>
      <pubDate>Wed, 25 May 2011 21:41:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816982#M45736</guid>
      <dc:creator>Brian_Triplett</dc:creator>
      <dc:date>2011-05-25T21:41:08Z</dc:date>
    </item>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816983#M45737</link>
      <description>Yes. First you call GetModuleHandle with a NULL argument to get a handle to the running EXE. Then you call GetFileVersionInfoEx to retrieve the version information. See the MSDN documentation on these routines for details. One of the things you have to do is get the "size" of the version info first, allocate a block of the desired size, and then get the actual data. I have done this in Fortran but don't think I have the code I used handy.</description>
      <pubDate>Wed, 25 May 2011 21:43:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816983#M45737</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-05-25T21:43:23Z</dc:date>
    </item>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816984#M45738</link>
      <description>Hi,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Please find enclosed a piece of code I use for retrieving the version number of a dll. I guess that you can adapt it to your needs.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Best regards,&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[fxfortran]      subroutine GetVersionInfoString(EXE_Name, VERSION_INFO)
      use DFWIN
      implicit none
C
      character(len=*), intent(in) ::  EXE_Name
      character(len=*), intent(out) :: VERSION_INFO
C
C     Reading the version number of an executable (or dll)
C
      integer(4)         Hndl
      integer(4)         nBytes
      integer(4)         rc
      character(len=256) StringInfo
      character(len=8)   CharSet
C
      integer(4)         uVersionLen, uTranslationLen
      integer(4)         lpstrVffInfo, lpstrVffInfo1
      integer(4)         hMem
      integer(4)         i
      character(len=256) lpversion
      integer(1)         lpTranslation(256)
      integer(4)         pTranslation
C
      nBytes = GetFileVersionInfoSize(EXE_Name, LOC(Hndl))
C
      if (nBytes /= 0) then
          hMem = GlobalAlloc(GMEM_MOVEABLE, int(nBytes))
          lpstrVffInfo = GlobalLock(hMem)
          rc = GetFileVersionInfo(EXE_Name, Hndl, nBytes, lpstrVffInfo)
          StringInfo = "\VarFileInfo\Translation"C
          rc = VersionQueryValue(lpstrVffInfo, loc(StringInfo), loc(lpTranslation), loc(uTranslationLen))
          write(CharSet,'(4z2.2)') lpTranslation(2),lpTranslation(1),lpTranslation(4),lpTranslation(3)
          StringInfo = "\StringFileInfo\"//CharSet//"\FileVersion\"C
          rc = VersionQueryValue(lpstrVffInfo, loc(StringInfo), loc(lpVersion), loc(uVersionLen))
          if (rc /= 0) then
              rc = lstrcpy(VERSION_INFO, lpVersion)
              uVersionLen = min(uVersionLen,index(VERSION_INFO,char(0)))
              do i=uVersionLen,LEN(VERSION_INFO)
                 VERSION_INFO(i:i) = ' '
              end do
          else
              VERSION_INFO = 'n.c'
	  end if
          rc = GlobalUnlock(hMem)
          rc = GlobalFree(hMem)
      else
          VERSION_INFO = 'n.c'
      end if
C
      return
      end
[/fxfortran]&lt;/PRE&gt; &lt;/DIV&gt;</description>
      <pubDate>Wed, 25 May 2011 22:05:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816984#M45738</guid>
      <dc:creator>netphilou31</dc:creator>
      <dc:date>2011-05-25T22:05:23Z</dc:date>
    </item>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816985#M45739</link>
      <description>&lt;P&gt;been messsing with this code and ran into a couple of things:&lt;BR /&gt;1) This uses DFWIN. Also works with IFWIN. Is there anydifference between DFWIN v IFWIN? &lt;BR /&gt;2) VersionInfoQuery now VerInfoQuery, changing doesn't seem to make any difference&lt;BR /&gt;3) on line rc = VerQueryValue(lpstrVffInfo, loc(StringInfo), loc(lpVersion), loc(uVersionLen))&lt;BR /&gt;it always returns 0&lt;BR /&gt;&lt;BR /&gt;Anyone look at code and see a problem/issue?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;b&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2011 15:04:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816985#M45739</guid>
      <dc:creator>bmchenry</dc:creator>
      <dc:date>2011-11-17T15:04:39Z</dc:date>
    </item>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816986#M45740</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I developed this portion of code with CVF (COMPAQ Visual Fortran). At that time the module name was DFWIN, but now with Intel Visual Fortran, it has been renamed IFWIN, although a compatibility module is still available. For the other issues I did not test the code using IVF.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2011 15:31:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816986#M45740</guid>
      <dc:creator>netphilou31</dc:creator>
      <dc:date>2011-11-17T15:31:23Z</dc:date>
    </item>
    <item>
      <title>Access version resource from code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816987#M45741</link>
      <description>aha! therein lies the issue!&lt;BR /&gt;i thought it was something that worked on IVF.&lt;BR /&gt;OK, that gives me a clue why it wasn't working as expected!&lt;BR /&gt;&lt;BR /&gt;also foundat&lt;BR /&gt;&lt;P&gt;&lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=78525&amp;amp;o=a&amp;amp;s=lr" target="_blank"&gt;http://software.intel.com/en-us/forums/showthread.php?t=78525&amp;amp;o=a&amp;amp;s=lr&lt;/A&gt;&lt;/P&gt;&lt;P&gt;from Steve:&lt;BR /&gt;The handles (hMem, etc.) should be declared INTEGER(HANDLE). The "lp" variables should be INTEGER(LPVOID).&lt;/P&gt;Guess i'll try that!&lt;BR /&gt;&lt;BR /&gt;thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Nov 2011 15:50:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816987#M45741</guid>
      <dc:creator>bmchenry</dc:creator>
      <dc:date>2011-11-17T15:50:25Z</dc:date>
    </item>
    <item>
      <title>Sorry to kick the topic, but</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816988#M45742</link>
      <description>&lt;P&gt;Sorry to kick the topic, but I encountered the same issue where the above code wouldn't work. After some tinkering and combining several posts on the internet, I got it working. Here's my code (works in IVF 11)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;#define MAX_PATH 260+1      

subroutine GetVersionInfoStrings(FILEVERSION)
	use IFWIN
	implicit none

	character(len=*), intent(out) :: FILEVERSION

	integer(4)         Hndl
	integer(4)         nBytes
	integer(4)         rc
	character(len=256) StringInfo

	integer(4)         uVersionLen
	integer(4)         lpstrVffInfo
	character(100)     lpVersion
	integer(4)         hMem
	integer(4)         i

	character(MAX_PATH) szFilename

	pointer(lplpVersion, lpversion)


	rc = GetModuleFileName(NULL, szFilename, MAX_PATH)
	nBytes = GetFileVersionInfoSize(szFilename, LOC(Hndl))

	if (nBytes /= 0) then
		hMem = GlobalAlloc(GMEM_MOVEABLE, int(nBytes))
		lpstrVffInfo = GlobalLock(hMem)
		rc = GetFileVersionInfo(szFilename, Hndl, nBytes, lpstrVffInfo )

		StringInfo = "\\StringFileInfo\\040904b0\\FileVersion"C  !hex 040904b0 is the code page set in the resource file
		rc = VerQueryValue(lpstrVffInfo, loc(StringInfo), lplpVersion, loc(uVersionLen))
		if (rc /= 0) then
			rc = lstrcpy(FILEVERSION, lpVersion)
			uVersionLen = min(uVersionLen,index(FILEVERSION,char(0)))
			do i=uVersionLen,len(FILEVERSION)
				FILEVERSION(i:i) = ' '
			end do
		else
			FILEVERSION = 'n.c'
		end if
 
		rc = GlobalUnlock(hMem)
		rc = GlobalFree(hMem)
	else
		FILEVERSION = 'n.c'
	end if
end&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2014 06:56:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816988#M45742</guid>
      <dc:creator>Michiel_Tukker</dc:creator>
      <dc:date>2014-10-10T06:56:07Z</dc:date>
    </item>
    <item>
      <title>Your code won't work in a 64</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816989#M45743</link>
      <description>&lt;P&gt;Your code won't work in a 64-bit application. See bmchenry's post above yours.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2014 17:59:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Access-version-resource-from-code/m-p/816989#M45743</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-10-10T17:59:42Z</dc:date>
    </item>
  </channel>
</rss>

