Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////
- // //
- // dllBridge@gmail.com
- //
- // 24 Dec 2021 (14:52)
- // 18 Sep 2020 (12:14)
- //
- #ifdef _MSC_VER
- #define _CRT_SECURE_NO_WARNINGS
- #endif
- #include <stdio.h>
- #include <string.h>
- #include <locale.h> // Здесь живёт setlocale()
- #include <windows.h>
- HINSTANCE hDll;
- char szPathDLL[111],
- szPathBase[100] = "C:\\dllBridge", // Default folder
- szWLError[201];
- int ProgramNumber = 299, //
- nPerson = 214, // User number
- (*Transit)[100];
- //////////////////////////////
- int* (*__getAdrBOSS)(int n);
- int (*__DisConnect)(int n);
- int dllBridge(const char *sz);
- #ifdef __cplusplus // g++ (C++) code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- namespace
- {
- struct WLMain
- {
- int res;
- /////////////////////////////////////////////// Transit[3][17] = 317;
- WLMain() // printf("\nres = %d \n", res);
- {
- res = dllBridge(szPathBase);
- if(res < 1) printf("%s \n", szWLError);
- else printf("The dllBridge.dll was successfully connected.\n");
- }
- ///////////////////////////////////////////////
- ~WLMain() //
- {
- if(res) __DisConnect(ProgramNumber);
- }
- } Obj;
- }
- #endif // #else // C code + + + + + + + + + + + + + + + + +
- ///////////////////////////////////////////////////////////////////////////////////////
- int dllBridge(const char *sz) //
- {
- if(hDll) FreeLibrary(hDll); // To reconnect DLL.
- else setlocale(LC_ALL, "Rus"); // The Cyrillic alphabet to a console application
- char sz1[201];
- strcpy(sz1, sz);
- strcat(sz1, "\\dllBridge.dll");
- hDll = LoadLibrary(sz1); //
- int res;
- if(hDll == 0)
- {
- res = 0;
- goto L_02;
- }
- __getAdrBOSS = (int*(*)(int))GetProcAddress(hDll, "__getAdrBOSS");
- Transit = (int(*)[100])__getAdrBOSS(ProgramNumber); // Second_Number);//
- if( Transit == 0) { res = -2; goto L_02; } // All connections are busy.
- if((int)Transit == -1) { res = -1; goto L_02; } // A program with this number is already connected.
- __DisConnect = (int (*)(int))GetProcAddress(hDll, "__DisConnect");
- strcpy(szPathDLL, sz1);
- Transit[10][0] = 2;
- memcpy(&Transit[10][1], "Console project", 15); // ! ! ! //memcpy(&Transit[10][1], szProjectInfo[1], 23);
- strcpy(szPathBase, sz); // szPathBase
- return (int)hDll ;
- L_02: FreeLibrary(hDll);
- switch(res)
- {
- case 0: strcpy(szWLError, "I can't load the library (dll)"); break;
- case -1: strcpy(szWLError, "A program with this number is already connected."); break;
- case -2: strcpy(szWLError, "All connections are busy.");
- } return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement