User Tools

Site Tools


wiki:new_face_of_generic_dll_in_vc_delphi_and_php

New face of generic DLL

Dll is a way to share the code with others on the Windows, and Mircosoft gives us three functions to call the functions in the DLL, they are LoadLibrary, FreeLibrary and GetProcAddress.

It is very easy to compile a dll, just follow the wizard.

VC

When you got your DLL, your first job is writing the test code to make sure the DLL works fine. Here's piece of codes

typedef int  (*DLLFC)(char* , int *);
DLLFC func;
HINSTANCE hInst = LoadLibrary("libcode.dll");
if (hInst != NULL)
{
    func= (DLLFC)GetProcAddress(hInst, "encode");
    func(src, &len);

As you see, LoadLibrary, open DLL file, and GetProcAddress, map the virtual address to the variable. You can call the function by the variable.

Delphi

You need a little time to call the functions if you're not familiar with Delphi.

procedure TForm1.Button1Click(Sender: TObject);
type
  DllFun=function(str:PChar; len:Pointer):Integer; cdecl;
var
  src:array[0..10240] of Char;
  func:DllFun;
  Tlib:Thandle;
  Tp:TFarProc;
  rc:Integer;
begin
  len := 0;
  Tlib := LoadLibrary('libcode.dll');
  if Tlib <> 0 then
  begin
    try
      Tp := GetProcAddress(Tlib, PChar('encode'));
      if Tp = nil then
        break;
      func := DllFun(Tp);
      rc := func(src, @len);

Look, same way as VC

PHP

I tried the w32api dll from php community. php_w32api.dll is out of date. php_ffi.dll can't catch up with the latest version. So I trid to wrap the DLL by myself. First, you need download the lasted binary/source packages, both of them. I downloaded php 5.2.6.

1. unpack them to your work directory: work
2. create the sample dll project.
3. modify the project setting, Project->Settings, or press ALT+F7
   a. switch to Win32 Release
   b. append 'ZEND_DEBUG=0,ZEND_WIN32,PHP_WIN32' to Preprocessror definitions (in C/C++ tab)
   c: append '/Tc' to Project Options (in C/C++ tab)
   d: append 'work\php-5.2.6,work\php-5.2.6\main,work\php-5.2.6\regex,work\php-5.2.6\TSRM,work\php-5.2.6\Zend' to Additional include directories (in C/C++ tab)
   e: append 'php5ts.lib kernel32.lib' to Object/library modules. (in Link tab)
   f: append 'yourwork\php\dev' to Additional library path (in Link tab)
   g: change the output filename to php_xxx.dll if you like
5. replace StdAfx.h
   #include "zend_config.w32.h"
   #include "php.h"
6. write code

the code

   ZEND_FUNCTION(encode);
   zend_function_entry EncModule_functions[] = {
      ZEND_FE(encode, NULL)
      {NULL, NULL, NULL}
   };
   zend_module_entry EncModule_module_entry = {
       STANDARD_MODULE_HEADER,
       "Encode Module",
       EncModule_functions,
       NULL, NULL, NULL, NULL, NULL,
       NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
   };    
   ZEND_GET_MODULE(EncModule)
   static ZEND_FUNCTION(encode)
   {
	char *str;
	int str_len;
	typedef int  (*DLLFC)(char* , int *);
	DLLFC func;
	char tmp[102400];
	HINSTANCE hInst;
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE){
           RETURN_LONG(-1);
        }
	hInst = LoadLibrary("libcode.dll");
	if (hInst == NULL)
		RETURN_LONG(-1);
	func= (DLLFC)GetProcAddress(hInst, "encode");
	if (func) {
	    func(tmp, &str_len);
 7. put php extension module dll to ext directory and put libcode.dll to php home directory
 8. edit php.ini, add the module dll name. (refer to the documents in php site)
 9. write your php testing code

Notice, you should use FreeLibrary to release the handle before quit.

finished.

Discussion

, http://herbalcakrawala.com, 2018/07/16 02:38

bismillahi » obat keputihan berlebihan dan berbau https://goo.gl/wexv5U , https://goo.gl/wexv5U , https://goo.gl/wexv5U , https://goo.gl/wexv5U , https://goo.gl/wexv5U

, https://goo.gl/QdCfTg, 2018/07/24 02:45

bismillahi » Cara Meningkatkan Kesuburan Wanita https://goo.gl/QdCfTg , https://goo.gl/QdCfTg , https://goo.gl/QdCfTg , https://goo.gl/QdCfTg , https://goo.gl/QdCfTg

, http://herbalcakrawala.com, 2018/07/30 04:47

bismillahi » obat asam urat https://goo.gl/FgofjW , https://goo.gl/FgofjW , https://goo.gl/FgofjW , https://goo.gl/FgofjW , https://goo.gl/FgofjW

, Tasikmalaya, 2018/07/30 06:46

http://www.agengoldgtasikmalaya.com/2018/07/cara-mudah-tuntaskan-masalah-keputihan-alami.html http://www.agengoldgtasikmalaya.com/2018/07/cara-mengobati-kista-bartholin-tanpa-operas-alami.html http://www.agengoldgtasikmalaya.com/2018/07/obat-mujarab-untuk-atasi-masalah-haid-yang-tidak-teratur.html http://www.agengoldgtasikmalaya.com/2018/06/walatra-bersih-wanita-solusi-semua-masalah-kewanitaan.html http://www.agengoldgtasikmalaya.com/2018/06/obat-herbal-pengencer-darah-kental.html http://www.agengoldgtasikmalaya.com/2018/06/ramuan-herbal-untuk-melancarkan-haid.html http://www.agengoldgtasikmalaya.com/2018/05/walatra-g-sea-jelly-gamat-original-alami.html http://www.agengoldgtasikmalaya.com/2018/05/obat-mujarab-penghilang-bopeng-bekas-jerawat.html http://www.agengoldgtasikmalaya.com/2018/04/obat-asam-lambung-tinggi-saat-puasa.html http://www.agengoldgtasikmalaya.com/2018/04/obat-sinusitis-alami-yang-sudah-terbukti-ampuh.html http://www.agengoldgtasikmalaya.com/2018/03/obat-herbal-infeksi-saluran-kencing.html http://www.agengoldgtasikmalaya.com/2018/02/obat-sembelit-herbal-untuk-anak-dan-dewasa.html http://www.agengoldgtasikmalaya.com/2018/01/solusi-terbaik-mengobati-syaraf-kejepit-tanpa-operasi.html http://www.agengoldgtasikmalaya.com/2017/12/obat-patah-tulang-alami-sudah-terbukti-ampuh.html http://www.agengoldgtasikmalaya.com/2017/11/cara-mempercepat-penyembuhan-luka-diabetes.html http://www.agengoldgtasikmalaya.com/2017/10/obat-kelenjar-getah-bening-alami-tanpa-operasi.html

, Liyoskin Pusat, 2018/08/02 02:16

http://www.creamwajah.enggalpesen.com/2017/12/07/krim-penghilang-flek-hitam-membandel-terbaik-aman-bpom/ http://www.creamwajah.enggalpesen.com/2017/12/02/cream-penghilang-flek-hitam-racikan-dokter-ampuh/ http://www.creamwajah.enggalpesen.com/2017/11/25/harga-liyoskin-di-apotik-berapa/ http://www.creamwajah.enggalpesen.com/2017/11/16/krim-pemutih-wajah-dan-penghilang-noda-hitam/ http://www.creamwajah.enggalpesen.com/2017/11/09/krim-pemutih-wajah-dan-penghilang-flek-hitam-yang-ampuh/ http://www.creamwajah.enggalpesen.com/2017/10/30/cream-penghilang-flek-hitam-menahun-yang-sulit-dihilangkan/ http://www.creamwajah.enggalpesen.com/2017/10/23/cream-pemutih-wajah-yang-banyak-dicari-dan-sedang-booming/ http://www.creamwajah.enggalpesen.com/2017/10/17/cream-wajah-ampuh-untuk-mengencangkan-kulit-wajah-yang-keriput/ http://www.creamwajah.enggalpesen.com/2017/10/11/cream-pemutih-wajah-dan-penghilang-flek-hitam-aman-yang-tidak-ada-di-apotik/ http://www.creamwajah.enggalpesen.com/2017/10/09/cream-wajah-untuk-mengecilkan-pori-pori-kulit-wajah-yang-ampuh/ http://www.creamwajah.enggalpesen.com/2017/10/06/cream-pelembab-wajah-untuk-kulit-kering-kusam-dan-berminyak-pria-wanita/ http://www.creamwajah.enggalpesen.com/2017/10/04/merk-krim-pemutih-wajah-herbal-yang-sangat-aman-dan-bagus-untuk-digunakan/ http://www.creamwajah.enggalpesen.com/2017/10/02/merk-cream-pemutih-wajah-alami-yang-cocok-untuk-umur-30-50-tahun/ http://www.creamwajah.enggalpesen.com/2017/09/30/cream-pemutih-wajah-berbahan-alami-yang-aman-bpom/ http://www.creamwajah.enggalpesen.com/2017/09/29/krim-penghilang-komedo-paling-ampuh/ http://www.creamwajah.enggalpesen.com/2017/09/27/cara-mengatasi-kulit-wajah-kering-akibat-ac/ http://www.creamwajah.enggalpesen.com/2017/09/25/cream-pemutih-wajah-yang-bagus-dan-cepat/ http://www.creamwajah.enggalpesen.com/2017/09/23/cara-mengatasi-dan-merawat-kulit-wajah-yang-kasar/ http://www.creamwajah.enggalpesen.com/2017/09/20/cream-wajah-yang-membuat-kinclong/ http://www.creamwajah.enggalpesen.com/2017/09/18/cara-menghaluskan-kulit-wajah-yang-kasar-tanpa-proses-pengelupasan-kulit/

, http://klikgamat.com, 2018/08/11 08:50

http://klikgamat.com http://www.klikgamat.com/2018/08/cara-mencegah-dan-mengobati-diare-pada-anak-dan-dewasa.html http://gamatori.com/2018/08/11/obat-alami-mencegah-menopause-dini-paling-ampuh/ http://gamatori.com/2018/08/10/obat-tradisional-untuk-miss-v-hitam-paling-ampuh/ http://www.klikgamat.com/2018/08/cara-mengatasi-muntaber-secara-cepat-dan-alami.html http://gamatori.com/2018/08/09/cara-menyembuhkan-miss-v-memar-akibat-benturan/ http://www.klikgamat.com/2018/08/cara-mengatasi-batuk-menahun-secara-alami.html http://gamatori.com/2018/08/08/obat-tradisional-vagina-bengkak-dan-bernanah/ http://gamatori.com/2018/08/08/cara-menyembuhkan-vagina-bernanah-paling-mujarab/ http://www.klikgamat.com/2018/08/obat-luka-bakar-pada-anak-paling-ampuh.html http://gamatori.com/2018/08/07/obat-keputihan-kuning-dan-berbau/ http://gamatori.com/2018/08/07/obat-miss-v-robek-disertai-sakit-dan-perih/ http://www.klikgamat.com/2018/08/obat-luka-bakar-alami-paling-ampuh.html http://gamatori.com/2018/08/06/obat-alami-keputihan-berlebih-saat-hamil/ http://gamatori.com/2018/08/06/cara-merapatkan-miss-v-dengan-ramuan-tradisional/ http://www.klikgamat.com/2018/08/obat-alami-kelenjar-getah-bening-bengkak-paling-ampuh.html http://gamatori.com/2018/08/04/obat-vagina-gatal-dan-mengelupas-paling-ampuh/ http://gamatori.com/2018/08/03/obat-alami-varises-vagina-pada-ibu-hamil/ http://gamatori.com/2018/08/02/obat-ngilu-pada-organ-kewanitaan-paling-ampuh/ http://gamatori.com/2018/08/02/cara-mengobati-bibir-kemaluan-tebal-dan-besar-sebelah/ http://gamatori.com/2018/08/01/cara-menghilangkan-jerawat-pada-miss-v/ http://gamatori.com/2018/08/01/obat-tradisional-vagina-mati-rasa-paling-ampuh/ http://gamatori.com/2018/07/31/obat-alami-untuk-keputihan-berwarna-coklat/ http://gamatori.com/2018/07/31/obat-alami-keputihan-bau-amis-paling-mujarab/

, http://klikgamat.com, 2018/08/13 06:52

http://gamatori.com/2018/08/13/penyebab-dan-cara-mengobati-kista-ovarium/ http://www.klikgamat.com/2018/08/cara-mengatasi-dan-mengobati-campak-pada-bayi-dan-anak.html http://www.klikgamat.com/2018/08/cara-mencegah-dan-mengobati-diare-pada-anak-dan-dewasa.html http://gamatori.com/2018/08/11/obat-alami-mencegah-menopause-dini-paling-ampuh/ http://gamatori.com/2018/08/10/obat-tradisional-untuk-miss-v-hitam-paling-ampuh/ http://www.klikgamat.com/2018/08/cara-mengatasi-muntaber-secara-cepat-dan-alami.html http://gamatori.com/2018/08/09/cara-menyembuhkan-miss-v-memar-akibat-benturan/ http://www.klikgamat.com/2018/08/cara-mengatasi-batuk-menahun-secara-alami.html http://gamatori.com/2018/08/08/obat-tradisional-vagina-bengkak-dan-bernanah/ http://gamatori.com/2018/08/08/cara-menyembuhkan-vagina-bernanah-paling-mujarab/ http://www.klikgamat.com/2018/08/obat-luka-bakar-pada-anak-paling-ampuh.html http://gamatori.com/2018/08/07/obat-keputihan-kuning-dan-berbau/ http://gamatori.com/2018/08/07/obat-miss-v-robek-disertai-sakit-dan-perih/ http://www.klikgamat.com/2018/08/obat-luka-bakar-alami-paling-ampuh.html http://gamatori.com/2018/08/06/obat-alami-keputihan-berlebih-saat-hamil/ http://gamatori.com/2018/08/06/cara-merapatkan-miss-v-dengan-ramuan-tradisional/ http://www.klikgamat.com/2018/08/obat-alami-kelenjar-getah-bening-bengkak-paling-ampuh.html http://gamatori.com/2018/08/04/obat-vagina-gatal-dan-mengelupas-paling-ampuh/ http://gamatori.com/2018/08/03/obat-alami-varises-vagina-pada-ibu-hamil/ http://gamatori.com/2018/08/02/obat-ngilu-pada-organ-kewanitaan-paling-ampuh/ http://gamatori.com/2018/08/02/cara-mengobati-bibir-kemaluan-tebal-dan-besar-sebelah/ http://gamatori.com/2018/08/01/cara-menghilangkan-jerawat-pada-miss-v/ http://gamatori.com/2018/08/01/obat-tradisional-vagina-mati-rasa-paling-ampuh/ http://gamatori.com/2018/07/31/obat-alami-untuk-keputihan-berwarna-coklat/

, Liyoskin, 2018/08/18 02:33

http://www.larismanis.enggalpesen.com/ http://www.aku.enggalpesen.com/ http://www.larismanis.enggalpesen.com/2018/08/14/krim-pencerah-wajah-untuk-kulit-berminyak-hasil-permanen/ http://www.larismanis.enggalpesen.com/2018/06/11/krim-pemutih-wajah-yang-aman-dan-permanen/ http://www.larismanis.enggalpesen.com/2018/03/09/krim-pencerah-wajah-untuk-kulit-berminyak-yang-aman/ http://www.larismanis.enggalpesen.com/2018/03/02/krim-pelicin-wajah-yang-hasilnya-permanen/ http://www.larismanis.enggalpesen.com/2018/02/23/cream-pemutih-dan-pelicin-kulit-wajah-yang-ampuh/ http://www.larismanis.enggalpesen.com/2018/02/17/krim-wajah-yang-aman-dipakai-untuk-semua-jenis-kulit/ http://www.larismanis.enggalpesen.com/2018/02/09/krim-pemutih-wajah-dan-penghilang-flek-hitam/ http://www.larismanis.enggalpesen.com/2018/02/03/krim-pencerah-wajah-terbaik-untuk-kulit-berminyak/ http://www.larismanis.enggalpesen.com/2018/01/26/krim-pemutih-wajah-yang-cocok-untuk-kulit-berminyak/ http://www.larismanis.enggalpesen.com/2018/01/20/krim-pemutih-wajah-untuk-kulit-berminyak-dan-kusam/ http://www.larismanis.enggalpesen.com/2018/01/12/cream-yang-cocok-untuk-kulit-sensitif-dan-berminyak/ http://www.larismanis.enggalpesen.com/2018/01/05/krim-pemutih-yang-cocok-untuk-kulit-berminyak/ http://www.larismanis.enggalpesen.com/2017/12/15/krim-pemutih-wajah-yang-tidak-mengandung-merkuri-dan-paraben/ http://www.larismanis.enggalpesen.com/2017/12/08/krim-pemutih-wajah-alami-untuk-wanita-karir/ http://www.larismanis.enggalpesen.com/2017/12/02/krim-pemutih-wajah-alami-untuk-pramugari/ http://www.larismanis.enggalpesen.com/2017/11/25/cream-pemutih-sekaligus-penghilang-flek-hitam-yang-ampuh/ http://www.larismanis.enggalpesen.com/2017/11/17/krim-pemutih-wajah-yang-aman-bagi-kulit-sensitif/ http://www.larismanis.enggalpesen.com/2017/11/10/merk-cream-pemutih-wajah-paling-ampuh-cepat-dan-permanen/ http://www.larismanis.enggalpesen.com/2017/11/03/krim-pemutih-wajah-alami-tanpa-efek-samping-aman-bpom/

, http://obatherbalterpercaya.com/obat-bisul/, 2018/08/20 04:47

bismillahi http://obatherbalterpercaya.com/obat-bisul/, http://obatherbalterpercaya.com/obat-bisul/

, Indonesia, 2018/09/15 00:51

Hopefully you can present interesting information again. https://bit.ly/2Oly2N3 https://bit.ly/2xj1Jar https://bit.ly/2p6jtSu https://bit.ly/2MupjX7

, Indonesia, 2018/09/18 00:57

Always we wait for the latest information. https://bit.ly/2NkYWbB https://bit.ly/2OzvBqi https://bit.ly/2D7LumG https://bit.ly/2piXbwV

, http://gamatori.com, 2018/10/03 03:34

www.klikgamat.com/2018/10/cara-menghilangkan-dan-menyamarkan-selulit-secara-alami.html http://gamatori.com/2018/10/03/cara-menyembuhkan-keputihan-gatal-dan-perih-secara-alami-yang-terbukti-ampuh/ http://gamatori.com/2018/10/01/obat-vagina-berbau-tidak-sedap-dan-keluar-lendir-putih/ http://www.klikgamat.com/2018/09/obat-alami-scabies-pada-manusia-paling-ampuh.html http://gamatori.com/2018/09/28/obat-alami-gatal-dan-bercak-putih-pada-vagina-paling-ampuh/ http://www.klikgamat.com/2018/09/obat-alami-kulit-bersisik-paling-cepat-tepat-dan-manjur.html http://gamatori.com/2018/09/25/obat-alami-bintil-bintil-pada-vagina-paling-ampuh/ http://www.klikgamat.com/2018/09/obat-alami-untuk-menghilangkan-kadas-kurap-secara-tradisional-paling-ampuh.html http://www.klikgamat.com/2018/09/obat-alami-gagal-jantung-paling-ampuh.html http://gamatori.com/2018/09/21/macam-macam-penyakit-kelamin-wanita-dan-cara-mengobatinya/ http://gamatori.com/2018/09/20/cara-mengobati-vulvitis-paling-ampuh-secara-alami/ http://gamatori.com/2018/09/19/cara-mengobati-infeksi-pada-klitoris-secara-alami/ http://www.klikgamat.com/2018/09/cara-mengobati-ginjal-bocor-secara-alami-paling-ampuh.html http://gamatori.com/2018/09/18/cara-mengobati-klitoris-lecet-secara-cepat-dan-tepat-paling-ampuh/ https://gamatori.com/2018/09/17/obat-klitoris-nyeri-seperti-di-tusuk-paling-ampuh/ http://www.klikgamat.com/2018/09/obat-alami-yang-mujarab-untuk-impetigo-paling-ampuh.html http://gamatori.com/2018/09/15/cara-menyuburkan-kandungan-secara-alami-paling-ampuh/ http://gamatori.com/2018/09/13/obat-alami-abses-vagina-paling-cepat-tepat-dan-ampuh/ http://www.klikgamat.com/2018/09/obat-alami-kaki-gajah-paling-cepat-tepat-dan-ampuh.html http://gamatori.com/2018/09/12/obat-penghilang-benjolan-pada-klitoris-yang-paling-ampuh-secara-alami/ http://www.klikgamat.com/2018/09/cara-mengobati-hepatitis-secara-alami-paling-ampuh.html http://gamatori.com/2018/09/11/obat-klitoris-nyeri-yang-paling-ampuh-secara-alami/ http://gamatori.com/2018/09/11/obat-alami-klitoris-luka-disertai-perih-palin

, Indonesia, 2018/10/22 02:09

We thank you very much for the information presented today. https://goo.gl/Y27BGG https://goo.gl/dioAap https://goo.gl/arqct6

, Indonesia, 2018/10/25 07:07

We thank you very much for the information presented on Wednesday. https://goo.gl/siUEx2 https://goo.gl/SJcD5y https://goo.gl/XqNh6A

, Ciamis-Indonesia, 2018/10/26 01:50

Thank you for sharing, for those of you who are looking for a good and safe diet for the body visit the following website; http://www.leptosinpusat.com/ http://www.leptosinpusat.com/obat-diet-leptosin-yang-aman-dan-baik-untuk-tubuh-wa-sms-0821-2004-3737/ http://www.leptosinpusat.com/peluang-bisnis-online-yang-menggiurkan-wa-0821-2004-3737/

Enter your comment. Wiki syntax is allowed:
 
wiki/new_face_of_generic_dll_in_vc_delphi_and_php.txt · Last modified: 2008/06/25 02:53 by fcmaster