mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 19:30:06 +00:00
Add support to core:windows to add/delete users.
main :: proc() {
using fmt;
using windows;
username := "testuser";
password := "testpass";
ok := add_user("", username, password);
fmt.printf("add_user: %v\n", ok);
pi := windows.PROCESS_INFORMATION{};
ok2, path := windows.add_user_profile(username);
fmt.printf("add_user_profile: %v, %v\n", ok2, path);
ok3 := windows.delete_user_profile(username);
fmt.printf("delete_user_profile: %v\n", ok3);
ok4 := windows.delete_user("", username);
fmt.printf("delete_user: %v\n", ok4);
// Has optional bool to not wait on the process before returning.
b := run_as_user(username, password, "C:\\Repro\\repro.exe", "Hellope!", &pi);
fmt.printf("run_as_user: %v %v\n", b, pi);
}
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package sys_windows
|
||||
|
||||
foreign import netapi32 "system:Netapi32.lib"
|
||||
|
||||
@(default_calling_convention="stdcall")
|
||||
foreign netapi32 {
|
||||
NetUserAdd :: proc(
|
||||
servername: wstring,
|
||||
level: DWORD,
|
||||
user_info: ^USER_INFO_1, // Perhaps make this a #raw_union with USER_INFO1..4 when we need the other levels.
|
||||
parm_err: ^DWORD,
|
||||
) -> NET_API_STATUS ---;
|
||||
NetUserDel :: proc(
|
||||
servername: wstring,
|
||||
username: wstring,
|
||||
) -> NET_API_STATUS ---;
|
||||
NetUserGetInfo :: proc(
|
||||
servername: wstring,
|
||||
username: wstring,
|
||||
level: DWORD,
|
||||
user_info: ^USER_INFO_1,
|
||||
) -> NET_API_STATUS ---;
|
||||
NetLocalGroupAddMembers :: proc(
|
||||
servername: wstring,
|
||||
groupname: wstring,
|
||||
level: DWORD,
|
||||
group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these.
|
||||
totalentries: DWORD,
|
||||
) -> NET_API_STATUS ---;
|
||||
NetLocalGroupDelMembers :: proc(
|
||||
servername: wstring,
|
||||
groupname: wstring,
|
||||
level: DWORD,
|
||||
group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these.
|
||||
totalentries: DWORD,
|
||||
) -> NET_API_STATUS ---;
|
||||
}
|
||||
Reference in New Issue
Block a user