ReactOS 0.4.16-dev-91-g764881a
movefile.cpp File Reference
#include "windows.h"
#include <stdio.h>
#include <tchar.h>
#include "stdlib.h"
#include "string.h"
Include dependency graph for movefile.cpp:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

void Usage ()
 
int ShowRegValue ()
 
int DeleteValue ()
 
int Generate ()
 
int Check ()
 
int _tmain (int argc, _TCHAR *argv[])
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 11 of file movefile.cpp.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
_TCHAR argv[] 
)

Definition at line 201 of file movefile.cpp.

202{
203 if( argc<2 ) {
204 Usage();
205 return 1;
206 }
207
208 if( 0 == strncmp(argv[1], "-g", 2) )
209 {
210 // generate test files and registry values
211 return Generate();
212 }
213 else if( 0 == strncmp(argv[1], "-c", 2) )
214 {
215 // check generated files
216 return Check();
217 }
218 else if( 0 == strncmp(argv[1], "-s", 2) )
219 {
220 //
221 return ShowRegValue();
222 }
223 else if( 0 == strncmp(argv[1], "-d", 2) )
224 {
225 return DeleteValue();
226 }
227 else
228 {
229 Usage();
230 return 1;
231 }
232
233 return 0;
234}
static int argc
Definition: ServiceArgs.c:12
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int DeleteValue()
Definition: movefile.cpp:60
void Usage()
Definition: movefile.cpp:19
int ShowRegValue()
Definition: movefile.cpp:28
int Check()
Definition: movefile.cpp:196
int Generate()
Definition: movefile.cpp:81
#define argv
Definition: mplay32.c:18

◆ Check()

int Check ( )

Definition at line 196 of file movefile.cpp.

197{
198 return 0;
199}

Referenced by _tmain(), START_TEST(), UITOOLS95_DFC_ButtonCheckRadio(), and UpdateStatus().

◆ DeleteValue()

int DeleteValue ( )

Definition at line 60 of file movefile.cpp.

61{
62 HKEY hKey;
63 LONG retValue;
64 // test registry entry
65 retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hKey);
66 if( ERROR_SUCCESS != retValue ) {
67 printf("RegOpenKeyEx err=%ld \n", retValue);
68 return 1;
69 }
70
71 retValue = RegDeleteValue(hKey, "PendingFileRenameOperations");
72 if( ERROR_SUCCESS != retValue ) {
73 printf("RegDeleteValue err=%ld \n", retValue);
74 }
75
77
78 return 0;
79}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define printf
Definition: freeldr.h:97
FxAutoRegKey hKey
#define KEY_SET_VALUE
Definition: nt_native.h:1017
long LONG
Definition: pedump.c:60
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegDeleteValue
Definition: winreg.h:508

Referenced by _tmain().

◆ Generate()

int Generate ( )

Definition at line 81 of file movefile.cpp.

82{
83 char sBuf[255];
86 BOOL fReturnValue;
87
88 const char szxReplacedFile[] = "c:\\testFileIsReplaced";
89 const char szxMovedFileWithRepl[] = "c:\\testFileShouldBeMovedW";
90 const char szxMovedFile[] = "c:\\testFileShouldBeMoved";
91 const char szxNewMovedFile[] = "c:\\testFileIsMoved";
92 const char szxDeletedFile[] = "c:\\testFileShouldBeDeleted";
93
94 memset(sBuf, 0xaa, sizeof(sBuf));
95
96 // create the first file for moving
98 szxMovedFile,
100 0,
101 NULL,
104 NULL);
105 if(NULL == hFile) {
106 printf("Can't create the %s file, err=%ld \n", szxMovedFile, GetLastError());
107 return 1;
108 }
109 WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
111
112 // create the second file for removing
114 szxDeletedFile,
116 0,
117 NULL,
120 NULL);
121 if(NULL == hFile) {
122 printf("Can't create the %s file, err=%ld \n", szxDeletedFile, GetLastError());
123 return 1;
124 }
125 WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
127
129 szxReplacedFile,
131 0,
132 NULL,
135 NULL);
136 if(NULL == hFile) {
137 printf("Can't create the %s file, err=%ld \n", szxReplacedFile, GetLastError());
138 return 1;
139 }
140 WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
142
143
145 szxMovedFileWithRepl,
147 0,
148 NULL,
151 NULL);
152 if(NULL == hFile) {
153 printf("Can't create the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
154 return 1;
155 }
156 WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
158
159
160 fReturnValue = MoveFileEx(
161 szxDeletedFile,
162 NULL,
164 if( !fReturnValue ) {
165 printf("Can't move the %s file, err=%ld \n", szxDeletedFile, GetLastError());
166 return 1;
167 }
168
169 ShowRegValue();
170
171 fReturnValue = MoveFileEx(
172 szxMovedFile,
173 szxNewMovedFile,
175 if( !fReturnValue ) {
176 printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError());
177 return 1;
178 }
179
180 ShowRegValue();
181
182 fReturnValue = MoveFileEx(
183 szxMovedFileWithRepl,
184 szxReplacedFile,
186 if( !fReturnValue ) {
187 printf("Can't move the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
188 return 1;
189 }
190
191 ShowRegValue();
192
193 return 0;
194}
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MoveFileEx
Definition: winbase.h:3878
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:400
#define CreateFile
Definition: winbase.h:3749

Referenced by _tmain(), and main().

◆ ShowRegValue()

int ShowRegValue ( )

Definition at line 28 of file movefile.cpp.

29{
30 BYTE lpBuff[255];
31 memset(lpBuff, 0, sizeof(lpBuff));
32
33 DWORD lSize = sizeof(lpBuff);
34 HKEY hKey;
35 LONG retValue;
36 // test registry entry
37 retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_QUERY_VALUE, &hKey);
38 if( ERROR_SUCCESS != retValue ) {
39 printf("RegOpenKeyEx err=%ld \n", retValue);
40 return 1;
41 }
42
43 retValue = RegQueryValueEx(hKey, "PendingFileRenameOperations", NULL, NULL, lpBuff, &lSize);
44 if( ERROR_SUCCESS != retValue ) {
45 printf("RegQueryValueEx err=%ld \n", retValue);
46 lSize = 0;
47 }
48
49 printf("reg data: \n");
50 for(UINT i=0; i<lSize; i++) {
51 printf("%c", lpBuff[i]);
52 }
53 printf("\n");
54
56
57 return 0;
58}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define RegQueryValueEx
Definition: winreg.h:524
unsigned char BYTE
Definition: xxhash.c:193

Referenced by _tmain(), and Generate().

◆ Usage()

void Usage ( void  )

Definition at line 19 of file movefile.cpp.

20{
21 printf(" Usage: smssTest.exe -g|c|s|d\n\
22 g - generate test files\n\
23 c - check files after reboot\n\
24 s - show registry entry\n\
25 d - delete registry value\n");
26}

Referenced by _tmain().