Subject Re: [firebird-support] Re: FireBird ODBC *Create* string
Author Venus Software Operations
Hi Dorin

You are a life saver. This works beautifully.

At 05:40 pm 05/02/2004, you wrote:

>Hi
>Try this code, it will create a user DSN that will not be displayed
>in Control Panel->ODBC


Here is my implementation of the same. Also I have now made it visible in
control Panel | ODBC. Thanks a lot for your help.

CreateForcedUserDSN()

LPARAMETERS tcDriverName, tcDSN, tcAttrib

*tcDriverName = "Microsoft ODBC for Oracle"
*tcDSN = name
*tcAttrib = string with DSN attributes, ';' as separator


IF pcount() < 3
RETURN .F.
ENDIF

IF VARTYPE(tcDriverName) <> "C" OR EMPTY(tcDriverName)
RETURN .F.
ENDIF

DO CASE
CASE tcDriverName = "VFP"
tcDriverName = ODBC_MS_VFP

CASE tcDriverName = "FB"
tcDriverName = ODBC_IBP_FIREBIRD
ENDCASE

IF VARTYPE(tcAttrib) <> "C" OR EMPTY(tcAttrib)
RETURN .F.
ENDIF


#DEFINE CR CHR(13)


LOCAL lnResult, lnDisplay, lnAttribCount, li, lcEntry, lcValue
LOCAL ARRAY laAttrib[1]


DECLARE RegCreateKeyEx IN ADVAPI32.DLL ;
INTEGER, STRING, INTEGER, STRING, INTEGER, INTEGER, INTEGER,
INTEGER @, ;
INTEGER @

DECLARE RegOpenKeyEx IN ADVAPI32.DLL ;
INTEGER, STRING, INTEGER, INTEGER, INTEGER @

DECLARE RegSetValueEx IN ADVAPI32.DLL ;
INTEGER, STRING, INTEGER, INTEGER, STRING, INTEGER


lnResult = 0
lnDisplay = 0


*create DSN key
RegCreateKeyEx(HKEY_CURRENT_USER, "SOFTWARE\ODBC\ODBC.INI\" + tcDSN, 0, ;
"REG_SZ", 0, SECURITY_ACCESS_MASK, 0, @lnResult, @lnDisplay)


*copy string with attributes to array and parse entries/values
lnAttribCount = ALINES(laAttrib, CHRTRAN(tcAttrib, ';', CR))

FOR li = 1 TO lnAttribCount
lcEntry = LEFT(laAttrib[li], ATC('=', laAttrib[li]) - 1)
lcValue = SUBSTR(laAttrib[li], ATC('=', laAttrib[li]) + 1)

RegSetValueEx(lnResult, lcEntry, 0 , 1, lcValue, LEN(lcValue) + 1)
NEXT


*register DSN key
RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", ;
0, SECURITY_ACCESS_MASK, @lnResult)

RegSetValueEx(lnResult, tcDSN, 0 , 1, tcDriverName, LEN(tcDriverName) + 1)




Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
venussoftop@...
venussoftop@...
venussoftop@...
venussoftop@...
vso_ad1@...
___________________________________________


Please note: We reserve complete rights for policy changes in the future
and the same will be applicable immediately as and when made. Attachments
may get corrupted before reaching you, in such a situation please let us
know and we will resend you the same at the earliest. We do not take any
responsibility for data loss of any type and kind. Data safety remains the
sole the responsibility of the users of our softwares.
___________________________________________

Internet email confidentiality:

This message may contain information that may be privileged or
confidential. If you are not the addressee nor are you responsible for the
delivery of the message to the addressee indicated in this email, then you
may not copy or deliver this email to anyone and you should notify the
sender by reply email and then destroy this message.

Please reply email immediately to this message with REMOVE in the subject,
if you or your employer do not consent to email of this kind.

Opinions, conclusions and other information in this message that do not
relate to the official business of my firm shall be understood as neither
given nor endorsed by my company.


----------


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.577 / Virus Database: 366 - Release Date: 03/02/2004


[Non-text portions of this message have been removed]