summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/wince/wininc/cemiss.inc
blob: c510e9131bd9fb20b5fb2a43c1677e7dca6c14d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2006 by the Free Pascal development team.

    Contains missing wince functions present in win32 api

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}
{
  *What should contain this file*
  
  functions missing on wince api

}

{$ifdef read_interface}

function LoadLibraryA(lpLibFileName:LPCSTR):HINST;
function RegCreateKeyExA(hKey:HKEY; lpSubKey:LPCSTR; Reserved:DWORD; lpClass:LPSTR; dwOptions:DWORD;samDesired:REGSAM; lpSecurityAttributes:LPSECURITY_ATTRIBUTES; var hkResult: HKEY; lpdwDisposition:LPDWORD):LONG;
function RegDeleteKeyA(hKey:HKEY; lpSubKey:LPCSTR):LONG;
function RegDeleteValueA(hKey:HKEY; lpValueName:LPCSTR):LONG;
function RegEnumKeyExA(hKey:HKEY; dwIndex:DWORD; lpName:LPSTR; var cbName:DWORD; lpReserved:LPDWORD;lpClass:LPSTR; lpcbClass:LPDWORD; lpftLastWriteTime:PFILETIME):LONG;
function RegEnumValueA(hKey:HKEY; dwIndex:DWORD; lpValueName:LPSTR; var cbValueName: DWORD; lpReserved:LPDWORD;lpType:LPDWORD; lpData:pointer; lpcbData:LPDWORD):LONG;
function RegQueryValueExA(hKey:HKEY; lpValueName:LPCSTR; lpReserved:LPDWORD; lpType:LPDWORD; lpData:pointer;lpcbData:LPDWORD):LONG;
function RegQueryInfoKeyA(hKey:HKEY; lpClass:LPSTR; lpcbClass:LPDWORD; lpReserved:LPDWORD; lpcSubKeys:LPDWORD;lpcbMaxSubKeyLen:LPDWORD; lpcbMaxClassLen:LPDWORD; lpcValues:LPDWORD; lpcbMaxValueNameLen:LPDWORD;
  lpcbMaxValueLen:LPDWORD;lpcbSecurityDescriptor:LPDWORD; lpftLastWriteTime:PFILETIME):LONG;
function RegOpenKeyExA(hKey:HKEY; lpSubKey:LPCSTR; ulOptions:DWORD; samDesired:REGSAM; var hkResult: HKEY):LONG;
function RegSetValueExA(hKey:HKEY; lpValueName:LPCSTR; Reserved:DWORD; dwType:DWORD; lpData:pointer;cbData:DWORD):LONG;

{$endif read_interface}


{$ifdef read_implementation}

function LoadLibraryA(lpLibFileName:LPCSTR):HINST;
var  ws: PWideChar;
begin
  ws:=PCharToPWideChar(lpLibFileName);
  Result:=Windows.LoadLibrary(ws);
  FreeMem(ws);
end;

function RegCreateKeyExA(hKey:HKEY; lpSubKey:LPCSTR; Reserved:DWORD; lpClass:LPSTR; dwOptions:DWORD;samDesired:REGSAM; lpSecurityAttributes:LPSECURITY_ATTRIBUTES; var hkResult: HKEY; lpdwDisposition:LPDWORD):LONG;
var  lpwsSubKey,
     lpwsClass: PWideChar;
begin
 lpwsSubKey:=PCharToPWideChar(lpSubKey);
 lpwsClass:=PCharToPWideChar(lpClass);
 Result:=RegCreateKeyExW(hKey,lpwsSubKey,Reserved,lpwsClass,dwOptions,samDesired,lpSecurityAttributes, hkResult,lpdwDisposition);
 FreeMem(lpwsClass); FreeMem(lpwsSubKey);
end;

function RegDeleteKeyA(hKey:HKEY; lpSubKey:LPCSTR):LONG;
var  lpwsSubKey: PWideChar;
begin
 lpwsSubKey:=PCharToPWideChar(lpSubKey);
 Result:=RegDeleteKeyW(hKey,lpwsSubKey);
 FreeMem(lpwsSubKey);
end;

function RegDeleteValueA(hKey:HKEY; lpValueName:LPCSTR):LONG;
var  lpwsValueName: PWideChar;
begin
 lpwsValueName:=PCharToPWideChar(lpValueName);
 Result:=RegDeleteValueW(hKey,lpwsValueName);
 FreeMem(lpwsValueName);
end;

function RegEnumKeyExA(hKey:HKEY; dwIndex:DWORD; lpName:LPSTR; var cbName:DWORD; lpReserved:LPDWORD;lpClass:LPSTR; lpcbClass:LPDWORD; lpftLastWriteTime:PFILETIME):LONG;
var
  ClassBuf, NameBuf: array[0..255] of WideChar;
  csz, nsz: DWORD;
begin
 csz:=SizeOf(ClassBuf) div SizeOf(WideChar);
 nsz:=SizeOf(NameBuf) div SizeOf(WideChar);
 Result:=RegEnumKeyExW(hKey, dwIndex, NameBuf, nsz, lpReserved, ClassBuf, @csz, lpftLastWriteTime);
 if cbName > nsz then
   WideToAnsiBuf(NameBuf, nsz, lpName, cbName);
 cbName:=nsz;
 if (Result = 0) and (lpcbClass <> nil) then begin
   if (lpClass <> nil) and (lpcbClass^ > csz) then
     WideToAnsiBuf(ClassBuf, csz, lpClass, lpcbClass^);
   lpcbClass^:=csz;
 end;
end;

function RegEnumValueA(hKey:HKEY; dwIndex:DWORD; lpValueName:LPSTR; var cbValueName: DWORD; lpReserved:LPDWORD;lpType:LPDWORD; lpData:pointer; lpcbData:LPDWORD):LONG;
var
  t, sz, nsz: DWORD;
  DataBuf: pointer;
  NameBuf: array[0..255] of WideChar;
begin
 if lpcbData <> nil then
   sz:=lpcbData^
 else
   sz:=0;
 if lpData <> nil then begin
   sz:=sz*2;
   GetMem(DataBuf, sz);
 end
 else
   DataBuf:=nil;
 nsz:=SizeOf(NameBuf) div SizeOf(WideChar);
 Result:=RegEnumValueW(hKey, dwIndex, NameBuf, @nsz, lpReserved, @t, DataBuf, @sz);
 if cbValueName > nsz then
   WideToAnsiBuf(NameBuf, nsz, lpValueName, cbValueName);
 cbValueName:=nsz;
 if Result = 0 then begin
   if lpType <> nil then
     lpType^:=t;
   if lpcbData <> nil then begin
     if (lpData <> nil) and (t in [REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ]) then
       sz:=WideCharToMultiByte(CP_ACP, 0, DataBuf, sz div SizeOf(WideChar), lpData, lpcbData^, nil, nil)
     else begin
       if sz > lpcbData^ then
         Result:=ERROR_MORE_DATA
       else
         if lpData <> nil then
           Move(DataBuf^, lpData^, sz);
     end;
     lpcbData^:=sz;
   end;
 end;
 if DataBuf <> nil then
   FreeMem(DataBuf);
end;

function RegQueryValueExA(hKey:HKEY; lpValueName:LPCSTR; lpReserved:LPDWORD; lpType:LPDWORD; lpData:pointer;lpcbData:LPDWORD):LONG;
var
  lpwsValueName: PWideChar;
  t, sz: DWORD;
  DataBuf: pointer;
begin
 if lpcbData <> nil then
   sz:=lpcbData^
 else
   sz:=0;
 if lpData <> nil then begin
   sz:=sz*2;
   GetMem(DataBuf, sz);
 end
 else
   DataBuf:=nil;
 lpwsValueName:=PCharToPWideChar(lpValueName);
 Result:=RegQueryValueExW(hKey, lpwsValueName, lpReserved, @t, DataBuf, @sz);
 FreeMem(lpwsValueName);
 if Result = 0 then begin
   if lpType <> nil then
     lpType^:=t;
   if lpcbData <> nil then begin
     if t in [REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ] then begin
       sz:=sz div SizeOf(WideChar);
       if lpData <> nil then
         sz:=WideCharToMultiByte(CP_ACP, 0, DataBuf, sz, lpData, lpcbData^, nil, nil);
     end
     else begin
       if sz > lpcbData^ then
         Result:=ERROR_MORE_DATA
       else
         if lpData <> nil then
           Move(DataBuf^, lpData^, sz);
     end;
     lpcbData^:=sz;
   end;
 end;
 if DataBuf <> nil then
   FreeMem(DataBuf);
end;

function RegQueryInfoKeyA(hKey:HKEY; lpClass:LPSTR; lpcbClass:LPDWORD; lpReserved:LPDWORD; lpcSubKeys:LPDWORD;lpcbMaxSubKeyLen:LPDWORD; lpcbMaxClassLen:LPDWORD; lpcValues:LPDWORD; lpcbMaxValueNameLen:LPDWORD;
  lpcbMaxValueLen:LPDWORD;lpcbSecurityDescriptor:LPDWORD; lpftLastWriteTime:PFILETIME):LONG;
var
  ClassBuf: array[0..255] of WideChar;
  csz: DWORD;
begin
 csz:=SizeOf(ClassBuf) div SizeOf(WideChar);
 Result:=RegQueryInfoKeyW(hKey, ClassBuf, @csz, lpReserved, lpcSubKeys , lpcbMaxSubKeyLen, lpcbMaxClassLen,
                          lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime);
 if (Result = 0) and (lpcbClass <> nil) then begin
   if (lpClass <> nil) and (lpcbClass^ > csz) then
     WideToAnsiBuf(ClassBuf, csz, lpClass, lpcbClass^);
   lpcbClass^:=csz;
 end;
end;

function RegOpenKeyExA(hKey:HKEY; lpSubKey:LPCSTR; ulOptions:DWORD; samDesired:REGSAM; var hkResult: HKEY):LONG;
var  lpwsSubKey: PWideChar;
begin
 lpwsSubKey:=PCharToPWideChar(lpSubKey);
 Result:=RegOpenKeyExW(hKey, lpwsSubKey, ulOptions, samDesired, hkResult);
 FreeMem(lpwsSubKey);
end;

function RegSetValueExA(hKey:HKEY; lpValueName:LPCSTR; Reserved:DWORD; dwType:DWORD; lpData:pointer;cbData:DWORD):LONG;
var
  lpwsValueName, ws: PWideChar;
  DataBuf: pointer;
  sz: DWORD;
begin
 lpwsValueName:=PCharToPWideChar(lpValueName);
 if dwType in [REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ] then begin
   if (cbData > 0) and (PChar(lpData)[cbData - 1] = #0) then
     Dec(cbData);
   ws:=PCharToPWideChar(lpData, cbData, @sz);
   cbData:=sz*SizeOf(WideChar);
   DataBuf:=ws;
 end
 else begin
   DataBuf:=lpData;
   ws:=nil;
 end;
 Result:=RegSetValueExW(hKey, lpwsValueName, Reserved, dwType, DataBuf, cbData);
 FreeMem(lpwsValueName);
 if ws <> nil then
   FreeMem(ws);
end;

{$endif read_implementation}