Commit 8c1f27a10020d0b3a0bd9697a77de0cdc3684938
1 parent
a58ef7ad
Exists in
master
and in
3 other branches
Adding convenience method for open windows registry.
Showing
3 changed files
with
67 additions
and
1 deletions
Show diff stats
lib3270.cbp
| ... | ... | @@ -230,6 +230,9 @@ |
| 230 | 230 | <Unit filename="src/core/windows/log.c"> |
| 231 | 231 | <Option compilerVar="CC" /> |
| 232 | 232 | </Unit> |
| 233 | + <Unit filename="src/core/windows/registry.c"> | |
| 234 | + <Option compilerVar="CC" /> | |
| 235 | + </Unit> | |
| 233 | 236 | <Unit filename="src/core/windows/resources.rc" /> |
| 234 | 237 | <Unit filename="src/core/windows/util.c"> |
| 235 | 238 | <Option compilerVar="CC" /> | ... | ... |
| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * @brief Win32 Registry functions. | |
| 33 | + */ | |
| 34 | + | |
| 35 | +#include <winsock2.h> | |
| 36 | +#include <windows.h> | |
| 37 | +#include <lib3270.h> | |
| 38 | + | |
| 39 | +LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY phkResult) { | |
| 40 | + | |
| 41 | + LSTATUS rc; | |
| 42 | + DWORD disp; | |
| 43 | + char * path; | |
| 44 | + | |
| 45 | + if(lpSubKey) | |
| 46 | + path = lib3270_strdup_printf(LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME) "\\%s",(const char *) lpSubKey); | |
| 47 | + else | |
| 48 | + path = strdup(LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME)); | |
| 49 | + | |
| 50 | + rc = RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,samDesired,NULL,phkResult,&disp); | |
| 51 | + if(rc != ERROR_SUCCESS) | |
| 52 | + rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,path,0,NULL,REG_OPTION_NON_VOLATILE,samDesired,NULL,phkResult,&disp); | |
| 53 | + | |
| 54 | + lib3270_free(path); | |
| 55 | + | |
| 56 | + return rc; | |
| 57 | +} | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -43,6 +43,11 @@ |
| 43 | 43 | #include <stdarg.h> |
| 44 | 44 | #include <errno.h> |
| 45 | 45 | |
| 46 | + #ifdef _WIN32 | |
| 47 | + #include <winsock2.h> | |
| 48 | + #include <windows.h> | |
| 49 | + #endif // _WIN32 | |
| 50 | + | |
| 46 | 51 | #ifndef ENOTCONN |
| 47 | 52 | #define ENOTCONN 126 |
| 48 | 53 | #endif // !ENOTCONN |
| ... | ... | @@ -1535,9 +1540,10 @@ |
| 1535 | 1540 | |
| 1536 | 1541 | LIB3270_EXPORT int lib3270_set_as400(H3270 *hSession, int on); |
| 1537 | 1542 | |
| 1538 | -#ifdef WIN32 | |
| 1543 | +#ifdef _WIN32 | |
| 1539 | 1544 | LIB3270_EXPORT const char * lib3270_win32_strerror(int e); |
| 1540 | 1545 | LIB3270_EXPORT const char * lib3270_win32_local_charset(void); |
| 1546 | + LIB3270_EXPORT LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY phkResult); | |
| 1541 | 1547 | |
| 1542 | 1548 | /** |
| 1543 | 1549 | * @brief Translate windows error code. | ... | ... |