- Timestamp:
- Jul 3, 2008 9:18:18 AM (16 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxControl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxControl/Makefile.kmk
r10129 r10142 36 36 VBoxControl.cpp \ 37 37 VBoxControl.rc 38 VBoxControl_LIBS += \ 39 $(VBOX_LIB_IPRT_GUEST_R3) 38 40 39 41 # VBoxControl.cpp uses VBOX_SVN_REV. -
trunk/src/VBox/Additions/WINNT/VBoxControl/VBoxControl.cpp
r10094 r10142 23 23 #include <malloc.h> 24 24 25 #include <iprt/string.h> 26 #include <iprt/stream.h> 25 27 #include <VBox/VBoxGuest.h> 26 28 #include <VBox/version.h> … … 951 953 if (!VALID_PTR(pszKey)) 952 954 return VERR_INVALID_POINTER; 953 if (!VALID_PTR(pszValue) && (pszValue != NULL)); 955 if ((pszValue != NULL) && !VALID_PTR(pszValue)) 956 return VERR_INVALID_POINTER; 954 957 int rc; 955 958 … … 1014 1017 static int handleGetGuestProperty(int argc, char *argv[]) 1015 1018 { 1019 HANDLE hDevice = INVALID_HANDLE_VALUE; 1020 uint32_t u32ClientID = 0; 1021 int rc = VINF_SUCCESS; 1022 char *pszKey = NULL; 1023 char szValue[svcInfo::KEY_MAX_VALUE_LEN]; 1024 1016 1025 if (argc != 1) 1017 1026 { … … 1019 1028 return 1; 1020 1029 } 1021 char szValue[svcInfo::KEY_MAX_VALUE_LEN]; 1022 HANDLE hDevice = INVALID_HANDLE_VALUE; 1023 uint32_t u32ClientID = 0; 1024 int rc = openGuestDevice(&hDevice); 1030 rc = RTStrCurrentCPToUtf8(&pszKey, argv[0]); 1025 1031 if (!RT_SUCCESS(rc)) 1026 printf("Failed to open the VirtualBox device, RT error %d\n", rc); 1032 RTPrintf("Failed to convert the key name to Utf8, error %Rrc\n", rc); 1033 if (RT_SUCCESS(rc)) 1034 { 1035 rc = openGuestDevice(&hDevice); 1036 if (!RT_SUCCESS(rc)) 1037 RTPrintf("Failed to open the VirtualBox device, error %Rrc\n", rc); 1038 } 1027 1039 if (RT_SUCCESS(rc)) 1028 1040 { 1029 1041 rc = hgcmConnect(hDevice, "VBoxSharedInfoSvc", &u32ClientID); 1030 1042 if (!RT_SUCCESS(rc)) 1031 printf("Failed to connect to the host/guest registry service, RT error %d\n", rc);1043 RTPrintf("Failed to connect to the host/guest registry service, error %Rrc\n", rc); 1032 1044 } 1033 1045 if (RT_SUCCESS(rc)) 1034 1046 { 1035 rc = hgcmInfoSvcGetProp(hDevice, u32ClientID, argv[0], szValue,1047 rc = hgcmInfoSvcGetProp(hDevice, u32ClientID, pszKey, szValue, 1036 1048 sizeof(szValue), NULL); 1037 1049 if (!RT_SUCCESS(rc) && (rc != VERR_NOT_FOUND)) 1038 printf("Failed to retrieve the property value, RT error %d\n", rc); 1039 } 1040 if (RT_SUCCESS(rc) || (VERR_NOT_FOUND == rc)) 1041 { 1042 if (RT_SUCCESS(rc)) 1043 printf("Value: %s\n", szValue); 1044 else 1045 printf("No value set!\n"); 1046 } 1050 RTPrintf("Failed to retrieve the property value, error %Rrc\n", rc); 1051 } 1052 if (VERR_NOT_FOUND == rc) 1053 RTPrintf("No value set!\n"); 1054 if (RT_SUCCESS(rc)) 1055 RTPrintf("Value: %S\n", szValue); 1047 1056 if (u32ClientID != 0) 1048 1057 hgcmDisconnect(hDevice, u32ClientID); 1049 1058 if (hDevice != INVALID_HANDLE_VALUE) 1050 1059 CloseHandle(hDevice); 1060 RTStrFree(pszKey); 1051 1061 return rc; 1052 1062 } … … 1064 1074 static int handleSetGuestProperty(int argc, char *argv[]) 1065 1075 { 1076 HANDLE hDevice = INVALID_HANDLE_VALUE; 1077 uint32_t u32ClientID = 0; 1078 int rc = VINF_SUCCESS; 1079 char *pszKey = NULL; 1080 char *pszValue = NULL; 1081 1066 1082 if (argc != 1 && argc != 2) 1067 1083 { … … 1069 1085 return 1; 1070 1086 } 1071 HANDLE hDevice = INVALID_HANDLE_VALUE; 1072 char *pszValue = NULL; 1073 if (2 == argc) 1074 pszValue = argv[1]; 1075 uint32_t u32ClientID = 0; 1076 int rc = openGuestDevice(&hDevice); 1087 rc = RTStrCurrentCPToUtf8(&pszKey, argv[0]); 1077 1088 if (!RT_SUCCESS(rc)) 1078 printf("Failed to open the VirtualBox device, RT error %d\n", rc); 1089 RTPrintf("Failed to convert the key name to Utf8, error %Rrc\n", rc); 1090 if (RT_SUCCESS(rc) && (2 == argc)) 1091 { 1092 rc = RTStrCurrentCPToUtf8(&pszValue, argv[1]); 1093 if (!RT_SUCCESS(rc)) 1094 RTPrintf("Failed to convert the key value to Utf8, error %Rrc\n", rc); 1095 } 1096 if (RT_SUCCESS(rc)) 1097 { 1098 rc = openGuestDevice(&hDevice); 1099 if (!RT_SUCCESS(rc)) 1100 RTPrintf("Failed to open the VirtualBox device, error %Rrc\n", rc); 1101 } 1079 1102 if (RT_SUCCESS(rc)) 1080 1103 { 1081 1104 rc = hgcmConnect(hDevice, "VBoxSharedInfoSvc", &u32ClientID); 1082 1105 if (!RT_SUCCESS(rc)) 1083 printf("Failed to connect to the host/guest registry service, RT error %d\n", rc);1106 RTPrintf("Failed to connect to the host/guest registry service, error %Rrc\n", rc); 1084 1107 } 1085 1108 if (RT_SUCCESS(rc)) 1086 1109 { 1087 rc = hgcmInfoSvcSetProp(hDevice, u32ClientID, argv[0], pszValue);1110 rc = hgcmInfoSvcSetProp(hDevice, u32ClientID, pszKey, pszValue); 1088 1111 if (!RT_SUCCESS(rc)) 1089 printf("Failed to store the property value, RT error %d\n", rc);1112 RTPrintf("Failed to store the property value, error %Rrc\n", rc); 1090 1113 } 1091 1114 if (u32ClientID != 0) … … 1093 1116 if (hDevice != INVALID_HANDLE_VALUE) 1094 1117 CloseHandle(hDevice); 1118 RTStrFree(pszKey); 1119 RTStrFree(pszValue); 1095 1120 return rc; 1096 1121 }
Note:
See TracChangeset
for help on using the changeset viewer.