IQ DIRECT

Blog

Navigation

  • Home
  • About us
  • Portfolio
  • Reviews
  • Blog
  • Contacts
[Code Sample] Retrieve C++ Application Version from VS_VERSION Resource

Sometimes you may need to retrieve the application version from its own resources. While sounding trivial, this task is not so easy to solve. While you can easily access string resources or dialog resources using the dedicated WinAPI functions, the version resource retrieval is not so easy. That's because the corresponding function VerQueryValue is intended for retrieving versions from another loaded module, not from own executable. So, how would you retrieve the application version from your own executable then?

Read more
Access single file from different threads or processes and maintain consistensy without using extra locks

Sometimes you want to access a single file from different processes or threads and maintain its consistency. The example may be a common database or just a counter. When the file is opened in read-only mode, the question is trivial. But what if you want to write from different threads? Here is the code sample. The idea is to use File.Open constructor with the FileShare.None option. This option allows only one thread to access the file (either for reading or writing) and deny all other threads. The other threads should catch IOException and try to access the file subsequently with a random delay.

Read more
[Code Snippet] Parse FB2 format book in C#

Here is the actual code snippet to parse FB2 format book using C#. FB2 File format is known as FictionBook format. FB2 is rather simple file format based on XML and basic HTML. The FB2 file contains sections. Sections can contain other sections as well as paragraphs. Paragraphs contain actual text and basic formatting. 

The program below loads all sections recursively and print their names to console. Also one can use the fb2verse variable to get the actual text of the paragraph. The approach below uses the XDocument class to get the XElements. The only trick with further parsing is to use the correct XNamespace. 

Read more

Page 31 of 77

  • 26
  • 27
  • 28
  • ...
  • 30
  • 31
  • 32
  • 33
  • 34
  • ...

Copyright ©2026 IQ DIRECT


main version