Who knows?
Oleksandr Alesinskyy, July 27, 2004 - 9:20 am UTC
>Also, the function is really GetPrivateProfileStringA <<=== A? why A? who
knows....
Because most of Windows functions that deal with strings have to versions - "A" for ANSI strings and "W" for Unicode (wide) strings. So GetPrivateProfileStringA has a counterpart GetPrivateProfileStringW. BTW, later one shall be used as Unicode file has to be read.
July 27, 2004 - 9:31 am UTC
there you go :)
thanks!
Nguyen Trung Viet, July 28, 2004 - 4:12 am UTC
Thanks!
my next question is which data type in oracle corresponds to DWORD type in C ?
July 28, 2004 - 8:16 am UTC
binary_integer -- i gave you the entire example?
Database OS
Arun Gupta, July 28, 2004 - 8:28 am UTC
Tom,
This is good. I never realized that a Windows dll function can be called from PL/SQL in this manner. I guess pointer operation won't be supported. Since the PL/SQL block would execute on the database side, I assume database has to be running on Windows. Is that right?
Thanks
July 28, 2004 - 12:50 pm UTC
the dll is invoked where the external procedure (extproc) is running -- which can actually be remote in 9i.
"pointers" are supported -- it is a pointer from the external procedure which is invoking the DLL.
Just a couple of comments.
Niall Litchfield, July 28, 2004 - 9:58 am UTC
It isn't just windows dlls that can be called this way. My understanding is that any platform that supports sharable C libraries can be used in this way.
In the particular example used here, reading a well structured text file from the OS it would seem to me that it would be easier just to refer to the text file as an external table.
A reader, July 28, 2004 - 4:06 pm UTC
it doesn't work with 9i (on win xp). metalink note 226739.1 explains as for 9i on windows platforms: "Oracle external procedure callouts do not support the _stdcall calling convention. Only the _cdecl convention is supported.".
does one have to write a "wrapper" in order to get it to work? but how to ...
July 28, 2004 - 7:44 pm UTC
a wrapper would 10000% be called for (i said as much)
"It can be very dangerous to call functions you did not write yourself. you have
no control over the datatypes!"
you write the wrapper in something that can do _cdecl, like C for example.
Would you mind to show us how to ...
A reader, August 29, 2004 - 5:02 am UTC
... code such a _stdcall2_cdecl-wrapper for your sample?
why did ORACLE stop supporting the interface it provided prior to 9i (the one you used)?
August 29, 2004 - 11:47 am UTC
what interface did we stop supporting?
but in anycase, I'm not a windows programmer at all - i was way back in the day but got a reprieve and went running back to unix, where C is normal.
so, not sure what you are asking for? there are examples shipped with the server software that should compile on your platform.
A reader, August 29, 2004 - 1:21 pm UTC
Hi Tom,
I am getting following errors
1 declare
2 str_out varchar2(255);
3 n number;
4 begin
5 n := pGetPrivateProfileString
6 ('SAMPLE_LIST',
7 'NameOfSample',
8 'NameOfSampleDefault',
9 str_out,255,
10 'C:\TEMP\test.ini');
11 dbms_output.put_line( 'n = ' || n );
12 dbms_output.put_line( 'str_out = ' || str_out );
13* end;
GAURANG@HARI >/
declare
*
ERROR at line 1:
ORA-28575: unable to open RPC connection to external procedure agent
ORA-06512: at "GAURANG.PGETPRIVATEPROFILESTRING", line 1
ORA-06512: at line 5
August 29, 2004 - 2:44 pm UTC
search for ora-28575 on this site, your listener and or tnsnames.ora configuration is not correct.
A reader, September 05, 2004 - 11:18 am UTC
Hi Tom,
getting following errors
GAURANG@HARI >declare
2 str_out varchar2(255);
3 n number;
4 begin
5 n := pGetPrivateProfileString
6 ('SAMPLE_LIST',
7 'NameOfSample',
8 'NameOfSampleDefault',
9 str_out,255,
10 'C:\TEMP\test.ini');
11 dbms_output.put_line( 'n = ' || n );
12 dbms_output.put_line( 'str_out = ' || str_out );
13 end;
14 /
declare
*
ERROR at line 1:
ORA-28595: Extproc agent : Invalid DLL Path
ORA-06512: at "GAURANG.PGETPRIVATEPROFILESTRING", line 1
ORA-06512: at line 5
My listener.ora
---------------
# listener.ora Network Configuration File: C:\oracle10g\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = extproc)
(ORACLE_HOME = C:\oracle10g)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = MAHARAJ)(PORT = 1521))
)
)
)
Tnanames.ora
==============
EXTPROC_CONNECTION_DATA.WORLD=
(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC))
)
(CONNECT_DATA =
(SID=extproc)
(PRESENTATION=RO)
)
)
Thanks
Wrapper for reading Registry
PrazY, September 04, 2009 - 1:06 am UTC
Tom,
Is it possible to use the same wrapper for reading registry values using SP or Function?
September 04, 2009 - 3:53 pm UTC
you tell me, what is involved in reading the registry - I've shown *the approach*, you use your knowledge of
a) plsql
b) windows api calls
and you tell us?
rE: Reg Read
PrazY, September 06, 2009 - 12:53 am UTC
Sure Tom! had looked into kernel32.dll function but coudn't be able to find a function for accessing registry. Will try with advapi32.dll and let you know the result.
Just raised this question to know whether it is feasible or not :).
Thanks!