תודה, אבל RET עדיין ריק.
הנה הקוד אחרי השינוי. אני רוצה לציין שיצירת ה INI עובדת כראוי, רק הקריאה ממנו לא. למה INI ? זה הכי מתאים למטרה של התוכנה, בהתחשב באלטרנטיבות. למשקיעים, מצורף קובץ ZIP עם הפרוייקט. (זה פרוייקט דמי זמני שימוזג אח"כ לפרוייקט האמיתי) תודה מראש !
ret = Space(255) 'Create buffer for string value nc = GetPrivateProfileString("StartUp", "PASSWORD", "NULL", ret, 255, App.Path & "\sample.ini") 'NC , no of character copied to the buffer MsgBox (ret)
והנה הקוד המלא, אולי מישהו יצליח למצוא את הבעייה.
Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long Private Sub Command1_Click() MsgBox (GetPrivateProfileInt("StartUp", "USERID", 0, App.Path & "\sample.ini")) End Sub Private Sub Command2_Click() ret = Space(255) 'Create buffer for string value nc = GetPrivateProfileString("StartUp", "PASSWORD", "NULL", ret, 255, App.Path & "\sample.ini") 'NC , no of character copied to the buffer MsgBox (ret) End Sub Private Sub Command3_Click() WritePrivateProfileString "StartUp", "PASSWORD", "system", App.Path & "\sample.ini" End Sub