Skip site navigation (1) Skip section navigation (2)

C-function, don't load external dll file

From: Przemek <pl65(at)poczta(dot)fm>
To: pgsql-hackers(at)postgresql(dot)org
Subject: C-function, don't load external dll file
Date: 2012-11-20 14:16:03
Message-ID: dkiarhjezeouzloxbkfi@kcqo (view raw or flat)
Thread:
Lists: pgsql-hackers
I write my dll files in visual studio 2010.The dll file (name fservice.dll), which has an external function, code write in c++ (VS2010, I have dll and lib files)char * convert(char *)I
 tested my fservice.dll in console application which called function in 
this dll. It was work fine. I have a problem when a write and tests in 
Postgrsql.Dll file witch has c-function, who exports and imports to postgresql:&nbsp;&nbsp;#include "postgres.h"
#include "fmgr.h" #include #include typedef char* (__cdecl *MYPROC)(char * value); __declspec( dllexport ) PG_FUNCTION_INFO_V1(transform); __declspec( dllexport ) Datum transform (PG_FUNCTION_ARGS) { HINSTANCE hinstLib= LoadLibrary("fservice.dll"); char * pointer; text *t = PG_GETARG_TEXT_P(0);if (hinstLib != NULL){  ProcAdd = (MYPROC) GetProcAddress(hinstLib, "convert");  pointer=ProcAdd("text"); FreeLibrary(hinstLib); }else PG_RETRUN_NULL();&nbsp;/* * code */ PG_RETURN_TEXT_P(new_t); }I
 have a problem because, mod is doesn't exists. Path to dll file I check
 before write. Compile this c-function, and when i debug i saw it 
HINSTANCE hinstLib it wasn't created. It wasn't NULL or any value, It 
wasn't exist. Finally my c-function doesn't use my function form 
external dll.How load dll and use my external function ?My external function form dll and LoadLibrary() is not called by dll program with called by Postgresql, Why?&nbsp;Przemek

pgsql-hackers by date

Next:From: Kohei KaiGaiDate: 2012-11-20 14:19:54
Subject: Re: [v9.3] OAT_POST_ALTER object access hooks
Previous:From: Przemek LisowskiDate: 2012-11-20 14:07:53
Subject: C-function, don't load external dll file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group