Hi,
I'm trying to read a file with my following sub:
Code:Public Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnedString$, ByVal RSSize&, ByVal FileName$)but after calling the subCode:Function ReadFile(ByVal File As String, Header As String, Var As String) As String Dim sSpaces As String ' Max string length Dim szReturn As String ' Return default value if not found szReturn = vbNullString sSpaces = Space$(5000) Try Call GetPrivateProfileString(Header, Var, szReturn, sSpaces, Len(sSpaces), File) ReadFile = RTrim$(sSpaces) ReadFile = Left$(ReadFile, Len(ReadFile) - 1) Catch ex As Exception MsgBox(String.Format("Error: [{0}] <Yerbato.Text.Files.ReadFile>", ex.Message)) ReadFile = "" End Try End FunctionI'll get this error:Code:MsgBox(File.ReadFile(Application.StartupPath & "/Data/Accounts/" & Username & ".bin", "ACCOUNT", "Username"))
How can I fix this?PInvokeStackImbalance was detected
Message: A call to PInvoke function 'Yerbato.Text.Files!Yerbato.Text.Files.clsFiles::GetPrivateProfileString' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.




Reply With Quote