🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
4 messages
4 total messages Started by �� Sun, 15 Mar 1998 00:00
VB�У�����޸�ע��?
#1970
Author: ��
Date: Sun, 15 Mar 1998 00:00
3 lines
584 bytes
���ʸ�λ���ˣ��ڣ֣�����ε��ã��У����޸�ע��?
ϣ����ָ��һ���Խ�лл��
Re: VB�У�����޸�ע��?
#1875
Author: Chen Yongchuang
Date: Mon, 16 Mar 1998 00:00
178 lines
9136 bytes
��VC5.0�𣿲鿴һ����İ����ļ��й������¸���API���õ�˵����
RegCreateKeyEx
RegOpenKeyEx
RegQueryValueEx
RegSetValueEX
RegCloseKey
��������д��һ�����úͶ�ȡע���Ĵ��룬������Ϊһ��ģ�������Ĺ����У�����
����
GetKeyValue,SetKeyValue����ע��?
ע�⣺����appRegisterPostionΪ����Ҫ����ijһ����µ�����ֵ������������޸�
��


'��ģ��Ϊ����winapi32�е�ע������������������

Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type

Public Const ERROR_SUCCESS = 0&
Public Const REG_OPTION_NON_VOLATILE = 0

Public Const REG_BINARY = 3
Public Const REG_DWORD = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_DWORD_LITTLE_ENDIAN = 4
Public Const REG_EXPAND_SZ = 2
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_RESOURCE_LIST = 8

' ע���ȫѡ��...
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const SYNCHRONIZE = &H100000
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY
Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002

Public Const appRegisterPosition = "Software\Test"  '������ע�����λ��

Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA"
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal
lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long,
lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long,
lpdwDisposition As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA"
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long,
ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA"
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long,
ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long
'�ַ��ð�ֵ���ͷ�ʽ
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA"
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long,
lpType As Long, ByVal lpData As Any, lpcbData As Long) As Long        '�ַ�
���ð�ֵ���ͷ�ʽ
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

'��ѯ��ֵ
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As
String, ByRef KeyVal As String) As Boolean
    Dim i As Long                                           ' ѭ��ָ��
    Dim rc As Long                                          ' ���ش���
    Dim hKey As Long                                        ' �򿪵�ע����
���
    Dim KeyValType As Long                                  ' ע���������
��
    Dim tmpVal As String                                    ' ע������ʱ��
����
    Dim KeyValSize As Long                                  ' ע�������Ĵ�
С
    '------------------------------------------------------------
    ' �ڸ�� {HKEY_LOCAL_MACHINE ������...} �´�ע���
    '------------------------------------------------------------
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' ��ע��
��

    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' ������...

    tmpVal = String$(1024, 0)                             ' ��������ռ�
    KeyValSize = 1024                                       ' ��DZ�����С

    '------------------------------------------------------------
    ' ����ע���ֵ...
    '------------------------------------------------------------
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
                         KeyValType, tmpVal, KeyValSize)    ' ���/������ֵ

    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' ������

    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 �����
Null ��β���ַ�...
        tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null �ҵ�����
�ַ���ȡ
    Else                                                    ' WinNT ����Ҫ��
Null �����ַ�...
        tmpVal = Left(tmpVal, KeyValSize)                   ' Null δ�ҵ���
����ȡ�ַ�
    End If
    '------------------------------------------------------------
    ' Ϊ��ת���������ֵ����..
    '------------------------------------------------------------
    Select Case KeyValType                                  ' �����������
...
    Case REG_SZ                                             ' �ַ���ע���
�������
        KeyVal = tmpVal                                     ' �����ַ�ֵ
    Case REG_DWORD                                          ' ˫����ע�����
������
        For i = Len(tmpVal) To 1 Step -1                    ' ת��ÿһλ
            KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' һ���ַ�һ����
��ؽ���ֵ
        Next
        KeyVal = Format$("&h" + KeyVal)                     ' ת��˫����Ϊ��
����
    End Select

    GetKeyValue = True                                      ' ���سɹ�
    rc = RegCloseKey(hKey)                                  ' �ر�ע���
    Exit Function                                           ' �˳�

GetKeyError:      ' �����������...
    KeyVal = ""                                             ' ���÷���ֵΪ��
�ַ�
    GetKeyValue = False                                     ' ����ʧ��
    rc = RegCloseKey(hKey)                                  ' �ر�ע���
End Function

'�����ַ��ֵ
Public Function SetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As
String, ByVal KeyVal As String) As Boolean
    Dim rc As Long                                          ' ���ش���
    Dim mkSa As SECURITY_ATTRIBUTES
    Dim kDisp As Long
    Dim hKey As Long                                        ' �򿪵�ע����
���
    '------------------------------------------------------------
    ' �ڸ�� {HKEY_LOCAL_MACHINE ������...} �´�ע���
    '------------------------------------------------------------
    rtnCode = RegCreateKeyEx(HKEY_LOCAL_MACHINE, appRegisterPosition, 0,
App.Title, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, mkSa, curhKey, kDisp)
    rc = RegCreateKeyEx(KeyRoot, KeyName, 0, "", _
            REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, _
            mkSa, hKey, kDisp)                              ' �������ע��
��

    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' ������...

    '------------------------------------------------------------
    ' ����������ע���ֵ...
    '------------------------------------------------------------
    rc = RegSetValueEx(hKey, SubKeyRef, 0, _
                         REG_SZ, KeyVal, Len(KeyVal) + 1)   ' ����/���ü�ֵ

    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' ������
    SetKeyValue = True                                      ' ���سɹ�
    rc = RegCloseKey(hKey)                                  ' �ر�ע���
    Exit Function                                           ' �˳�

GetKeyError:      ' �����������...
    SetKeyValue = False                                     ' ����ʧ��
    rc = RegCloseKey(hKey)                                  ' �ر�ע���

End Function
Re: VB~{VP#,Hg:NP^8DW"2a1m#?~}
#1863
Author: Pazee
Date: Fri, 27 Mar 1998 00:00
12 lines
704 bytes
use api,
GetProfileString ...
LPSTR GetRegKeyValue(LPSTR szKey, LPSTR szBuf, int cbBuf);
..... SetRegKeyValue....

~{P!Cw~} <concise@cenpok.net> ~{1;P4Hk5=NDUB~} <6egahf$fsh$2@bbs.nease.net> ~{VP~}...
> ~{GkNJ8wN;8_HK#,TZ#V#BVPHg:N5wSC#A#P#I@4P^8DW"2a1m#?~}
> ~{O#M{D\V85cR;OBCT=r#,P;P;#!~}
> 
> 
> 
Re: VB~{VP#,Hg:NP^8DW"2a1m#?~}
#1864
Author: Pazee
Date: Fri, 27 Mar 1998 00:00
11 lines
673 bytes
LPSTR GetRegKeyValue(LPSTR szKey, LPSTR szBuf, int cbBuf);
..... Set..........    


~{P!Cw~} <concise@cenpok.net> ~{1;P4Hk5=NDUB~} <6egahf$fsh$2@bbs.nease.net> ~{VP~}...
> ~{GkNJ8wN;8_HK#,TZ#V#BVPHg:N5wSC#A#P#I@4P^8DW"2a1m#?~}
> ~{O#M{D\V85cR;OBCT=r#,P;P;#!~}
> 
> 
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads