|
Author |
Message |
joe #1 / 6
|
 Help to delete pwl files
I have a program I am writing that allows a user to logout, then I want to capture the user name from the registry and use that name to delete their pwl file. I want to kill c:\windows\CurUser.pwl I can get it to echo me the correct curent user to a msgbox, so I know I am getting the right value assigned to CurUser. I am just braindead today on the right format. Thanks, Joe
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Johan Bechthu #2 / 6
|
 Help to delete pwl files
| I have a program I am writing that allows a user to logout, then I want to | capture the user name from the registry and use that name to delete their | pwl file. | | I want to kill c:\windows\CurUser.pwl Kill "c:\windows\" & CurUser & ".pwl" | | I can get it to echo me the correct curent user to a msgbox, so I know I am | getting the right value assigned to CurUser. I am just braindead today on | the right format. | | Thanks, | Joe | |
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Joe #3 / 6
|
 Help to delete pwl files
I tried that, but all I get back c:\windows\jsmith. The .pwl does not get added. Its like any string I place to the right is lost. Here is the code 'Reads User Name Dim s As String Dim cnt As Long Dim dl As Long Dim CurUser As String cnt = 199 s = String$(200, 0) dl = GetUserName(s, cnt) If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = "" 'Deletes user pwl file MsgBox CurUser ' CurUser value returns correct Kill "C:\windows\" & CurUser & ".pwl" ' This is the trouble spot ' Kill not working Thanks Joe
Quote:
> | I have a program I am writing that allows a user to logout, then I want to > | capture the user name from the registry and use that name to delete their > | pwl file. > | > | I want to kill c:\windows\CurUser.pwl > Kill "c:\windows\" & CurUser & ".pwl" > | > | I can get it to echo me the correct curent user to a msgbox, so I know I > am > | getting the right value assigned to CurUser. I am just braindead today on > | the right format. > | > | Thanks, > | Joe > | > |
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Johan Bechthu #4 / 6
|
 Help to delete pwl files
Joe, The problem is not killing the file, but the getting the username. GetUserName puts a null-terminated string in the buffervariable. When the username is "jsmith", is provides you with a 7-character long string holding "jsmith|" (| is the null-character). You have to change the line where you 'translate' the result op the API call to your variable like: If dl <> 0 Then CurUser = Left$(s, cnt - 1) Else CurUser = "" Hope this helps, Johan.
| I tried that, but all I get back c:\windows\jsmith. The .pwl does not get | added. Its like any string I place to the right is lost. | | Here is the code | | 'Reads User Name | Dim s As String | Dim cnt As Long | Dim dl As Long | Dim CurUser As String | cnt = 199 | s = String$(200, 0) | dl = GetUserName(s, cnt) | If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = "" | | | 'Deletes user pwl file | | MsgBox CurUser ' CurUser value returns correct | Kill "C:\windows\" & CurUser & ".pwl" ' This is the trouble spot | ' Kill not working | | Thanks | Joe | |
| >
| > | I have a program I am writing that allows a user to logout, then I want | to | > | capture the user name from the registry and use that name to delete | their | > | pwl file. | > | | > | I want to kill c:\windows\CurUser.pwl | > | > Kill "c:\windows\" & CurUser & ".pwl" | > | > | | > | I can get it to echo me the correct curent user to a msgbox, so I know I | > am | > | getting the right value assigned to CurUser. I am just braindead today | on | > | the right format. | > | | > | Thanks, | > | Joe | > | | > | | > | > | |
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
#5 / 6
|
 Help to delete pwl files
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Joe #6 / 6
|
 Help to delete pwl files
That did the trick!! Thanks
Quote: > Joe, > The problem is not killing the file, but the getting the username. > GetUserName puts a null-terminated string in the buffervariable. When the > username is "jsmith", is provides you with a 7-character long string holding > "jsmith|" (| is the null-character). > You have to change the line where you 'translate' the result op the API call > to your variable like: > If dl <> 0 Then CurUser = Left$(s, cnt - 1) Else CurUser = "" > Hope this helps, > Johan.
> | I tried that, but all I get back c:\windows\jsmith. The .pwl does not get > | added. Its like any string I place to the right is lost. > | > | Here is the code > | > | 'Reads User Name > | Dim s As String > | Dim cnt As Long > | Dim dl As Long > | Dim CurUser As String > | cnt = 199 > | s = String$(200, 0) > | dl = GetUserName(s, cnt) > | If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = "" > | > | > | 'Deletes user pwl file > | > | MsgBox CurUser ' CurUser value returns correct > | Kill "C:\windows\" & CurUser & ".pwl" ' This is the trouble spot > | ' Kill not working > | > | Thanks > | Joe > | > |
> | >
> | > | I have a program I am writing that allows a user to logout, then I > want > | to > | > | capture the user name from the registry and use that name to delete > | their > | > | pwl file. > | > | > | > | I want to kill c:\windows\CurUser.pwl > | > > | > Kill "c:\windows\" & CurUser & ".pwl" > | > > | > | > | > | I can get it to echo me the correct curent user to a msgbox, so I know > I > | > am > | > | getting the right value assigned to CurUser. I am just braindead > today > | on > | > | the right format. > | > | > | > | Thanks, > | > | Joe > | > | > | > | > | > > | > > | > |
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
|
|