Monday 15 July 2013

kernel32 - GetPrivateProfileString returning no values :VB.net -


I am new to VB and working on VB6 on VB6 migration. One of the solutions has been successfully migrated and the other one is working on. ("WinFlex", "UserPath", "", Temporarily) as the slow-integer = GetPrivateProfileString (1024) in the form of a slow temporary New System.Text.StringBuilder (1024) Public Sub Main () , 1024, "C: \ WINDOWS \ win.ini") End Sub & LT; DllImport ("kernel32") & gt; _Private Function GetPrivateProfileString (ByVal section string, as byVal key string, as def string, ByVal retval as System.Text.StringBuilder, ByVal size integer, ByVal FilePath string as in the form of as ByVal ) As the integer end function

This special code (temporary) needs to return a functional directory for my INI file (like some "C: \ WinFlex6 \ 1 "), but instead it gives me an empty value Is returning. The same code works on a different solution (someone else migrates it). I'm not sure what the problem is. I tried to fix several fixes on the web, but none worked.

Can anyone help me on this?

Earlier it was working fine, but after some debugging stop working.

Sorry guys, I'm naive in vb so was making this silly mistake. . Thank you for bringing this

The issue was, I was declaring / function in a module

 . & Lt; DllImport ("kernel32") & gt; _Private Function GetPrivateProfileString (ByVal section string, as byVal key string, as def string, ByVal retval as System.Text.StringBuilder, ByVal size integer, ByVal FilePath string as in the form of as ByVal ) As an integer end function  

This function can be "shared function" which can be added to a class.

  public shared function  

I declared it as a vb square inside

   

bingo! It worked! Thanks again!


No comments:

Post a Comment