Advertisement
dllbridge

Untitled

Dec 1st, 2023
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.64 KB | None | 0 0
  1. // Язык Си ! ! ! ! ! !
  2.  
  3. #include     <stdio.h>
  4.  
  5.  
  6.  
  7.  
  8. int max(int n1,int n2);      
  9.  
  10. double fmax(double f1,double f2);    
  11.  
  12.  
  13.  
  14. int (*A)(int, int) = max;
  15.  
  16. double (*B)(double f1,double f2) = fmax;  
  17.  
  18. ////////////////////////////////////////////////////   (char(*)( ) )
  19. int main()                                        //   (int(*)(int))
  20. {
  21.    
  22.    
  23.     printf("%d  \n",    A(73  , 21   ));
  24.     printf("%.2f\n",    B(1.77, 3.55 ));    
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. //////////////////////////////////////////////
  36. int max(int n1,int n2)                      //
  37. {
  38.    
  39.     if(n1 > n2) return n1;
  40.    
  41. return n2; 
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. //////////////////////////////////////////////
  49. double fmax(double f1,double f2)             //
  50. {
  51.    
  52.     if(f1 > f2) return f1;
  53.    
  54. return f2; 
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. /*
  81. 0) extern "C" __declspec(dllexport)
  82.    - - - - - - - - - - - - - - - - -
  83. 1) int (*_rr)();
  84. 2) HMODULE  hDll = 0;
  85. 3) hDll = LoadLibrary("dll/for.dll");
  86. 4) _rr = (int(*)())GetProcAddress(hDll, "_rr");
  87. 5) FreeLibrary(hDll);
  88. */
  89.  
  90. /*
  91.  
  92. #include     <stdio.h>
  93. #include   <windows.h>
  94.  
  95.  
  96. HMODULE  hDll = 0;
  97. int  (*_foo )(int);
  98. char (*_SONY)(   );
  99.  
  100.  
  101.  
  102.  
  103. ////////////////////////////////////////////////////   (char(*)( ) )
  104. int main()                                        //   (int(*)(int))
  105. {
  106.    
  107.     hDll = LoadLibrary("my/dll_02.dll");
  108.  
  109.     printf("hDll = %d\n", hDll);
  110.    
  111.     _SONY = GetProcAddress(hDll, "_SONY");
  112.     _foo  = GetProcAddress(hDll, "_foo" );
  113.    
  114.    
  115.     for (int i = 0;i < 13; i++)
  116.     {
  117.         printf ("%c" , _SONY());
  118.     }
  119.    
  120.     printf("foo return %d\n", _foo(1000) );
  121.    
  122.  
  123.    
  124.    
  125. }
  126.  
  127.  
  128.  
  129.  
  130. */
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement