How can I read the history file using kernell32 library in mql4 and mql5?
In MetaTrader v5 history files are encrypted so you can't read them form external source, but obviously in MQL5 you can read the data directly so there is no need o use the Kernal32 library.
In MetaTrader v4 history files are not encrypted, but also you can read the data directly as well without the need for the Kernal32 library.
As I have stated, in MetaTrader v5, you can't read the History file directly because it is encrypted, but you can just read the data directly by using the CopyRates() function. You can even read tick data directly as well with the CopyTicksRange() function.
Even on MetaTrader v4, there is no need to read the history directly, unless you are trying to circumvent the Strategy Tester to look ahead and thus produce false trading results, which is unethical.
I have given you the link to the documentation which includes example code.
There are also examples in the CodeBase: https://www.mql5.com/en/search#!keyword=CopyRates&module=mql5_module_codebase
Learn to use the Search function!