Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. regsvr32 failed

regsvr32 failed

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++visual-studiocom
7 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devvvy
    wrote on last edited by
    #1

    QUESTION 1: i typed at the command prompt: C:\somefolder\regsrv32 mysever.dll Error from regsrv32: "myserver.dll" is not an executable file and no registration help is registered for this file type. and C:\somfolder\regsrv32 /u myserver.dll Error from regsrv32: same as above. It's an ATL-Wizard created COM btw. QUESTION 2: btw, I also tried to register and unregister with WinExec. Is there anything wrong? forward slashes Vs back slashes? #include "stdafx.h" #include #include int main(int argc, char* argv[]) { int nRetCode = 0; nRetCode = WinExec("RegSvr32 /u C:\Program Files\RealTime7\QueryGenAlpha\QueryGenAlpha.dll", SW_SHOW); if(nRetCode <= 31) { cout << "WinExec failed..." << endl; } return 0; } The error was not reported thru the console (ie. nRetCode>31), but: (a) A pop up from regsvr32 appeared, and: "LoadLibrary("C:Program" failed - the specified module cannot be found" (b) I also tried to call LoadLibrary from client directly. But LoadLibrary failed. And GetLastError() reported after call to LoadLibrary: 193 is not a valid Win32 application. ERROR_BAD_EXE_FORMAT Code as follows: HINSTANCE hLib; hLib = LoadLibrary(_T(pszDll)); //STEP 2: un-register server if(hLib!=NULL) { PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllUnregisterServer")); if(pFunc!=NULL) { //Unregister the server! pFunc(); } else { //Additional exception handling here. dwError = GetLastError(); return 0; } } else { //Additional exception handling here. dwError = GetLastError(); return 0; } One last thing: When I build (Ctrl-F5) the ATL COM server project, I had no problem at all. THe server get registered, and I tested the server from VB client and it worked! Thanks! norm

    D P 2 Replies Last reply
    0
    • D devvvy

      QUESTION 1: i typed at the command prompt: C:\somefolder\regsrv32 mysever.dll Error from regsrv32: "myserver.dll" is not an executable file and no registration help is registered for this file type. and C:\somfolder\regsrv32 /u myserver.dll Error from regsrv32: same as above. It's an ATL-Wizard created COM btw. QUESTION 2: btw, I also tried to register and unregister with WinExec. Is there anything wrong? forward slashes Vs back slashes? #include "stdafx.h" #include #include int main(int argc, char* argv[]) { int nRetCode = 0; nRetCode = WinExec("RegSvr32 /u C:\Program Files\RealTime7\QueryGenAlpha\QueryGenAlpha.dll", SW_SHOW); if(nRetCode <= 31) { cout << "WinExec failed..." << endl; } return 0; } The error was not reported thru the console (ie. nRetCode>31), but: (a) A pop up from regsvr32 appeared, and: "LoadLibrary("C:Program" failed - the specified module cannot be found" (b) I also tried to call LoadLibrary from client directly. But LoadLibrary failed. And GetLastError() reported after call to LoadLibrary: 193 is not a valid Win32 application. ERROR_BAD_EXE_FORMAT Code as follows: HINSTANCE hLib; hLib = LoadLibrary(_T(pszDll)); //STEP 2: un-register server if(hLib!=NULL) { PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllUnregisterServer")); if(pFunc!=NULL) { //Unregister the server! pFunc(); } else { //Additional exception handling here. dwError = GetLastError(); return 0; } } else { //Additional exception handling here. dwError = GetLastError(); return 0; } One last thing: When I build (Ctrl-F5) the ATL COM server project, I had no problem at all. THe server get registered, and I tested the server from VB client and it worked! Thanks! norm

      D Offline
      D Offline
      devvvy
      wrote on last edited by
      #2

      just found this link: http://support.microsoft.com/default.aspx?scid=KB;en-us;q249873 not sure if i can spot the problem.... norm

      D 1 Reply Last reply
      0
      • D devvvy

        just found this link: http://support.microsoft.com/default.aspx?scid=KB;en-us;q249873 not sure if i can spot the problem.... norm

        D Offline
        D Offline
        devvvy
        wrote on last edited by
        #3

        i figured out the problem, the dll was corrupted in the process of copying it from CD to destination folder.. anyway, i fixed that. Now i tried to LoadLibrary to access DllUnregisterServer and DllRegisterServer... i load the dll via LoadLibrary and called: STEP 1: GetProcAddress(hLib, _T("DllUnregisterServer") proceed to un-register the dll. STEP 2: GetProcAddress(hLib, _T("DllRegisterServer") proceed to register the dll. i still have some trouble. i lauch the VB client and it stop working. tried to open keys from registry and registry complained "error openning key" ... (somehting close to that) since DllRegisterServer is implemented by ATL Wizard, I assume there's nothing wrong with it (MS never produces buggy code right? ) so, THREE prime suspect: SUSPECT 1: PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllRegisterServer")); //SUSPECT 1: Name mingling.. but pFunc is NOT NULL. So, this is cleared. if(pFunc!=NULL) { //register the server! pFunc(); } SUSPECT 2: typedef void (*PFUNC) (void); does it matches the signature of..? STDAPI DllRegisterServer(void) I am a bit confused by STDAPI, but I just ignore it for the moment... But SUSPECT 2 is the only remaining p ossibility i can see. SUSPECT 3: the installation program i write now call DllUnregisterServer before installing a clean copy. But the old dll may reside in a different folder. if I call DllUnregisterServer by loading the new dll (in attempt to unregister the old dll...?) you think this will be a problem? SUSPECT 4: RegSvr32 does more than just load the dll and call DllRegisterServer and DllUnregisterServer. Developer should not attempt to call these two methods directly and should stick with RegSvr32? norm

        1 Reply Last reply
        0
        • D devvvy

          QUESTION 1: i typed at the command prompt: C:\somefolder\regsrv32 mysever.dll Error from regsrv32: "myserver.dll" is not an executable file and no registration help is registered for this file type. and C:\somfolder\regsrv32 /u myserver.dll Error from regsrv32: same as above. It's an ATL-Wizard created COM btw. QUESTION 2: btw, I also tried to register and unregister with WinExec. Is there anything wrong? forward slashes Vs back slashes? #include "stdafx.h" #include #include int main(int argc, char* argv[]) { int nRetCode = 0; nRetCode = WinExec("RegSvr32 /u C:\Program Files\RealTime7\QueryGenAlpha\QueryGenAlpha.dll", SW_SHOW); if(nRetCode <= 31) { cout << "WinExec failed..." << endl; } return 0; } The error was not reported thru the console (ie. nRetCode>31), but: (a) A pop up from regsvr32 appeared, and: "LoadLibrary("C:Program" failed - the specified module cannot be found" (b) I also tried to call LoadLibrary from client directly. But LoadLibrary failed. And GetLastError() reported after call to LoadLibrary: 193 is not a valid Win32 application. ERROR_BAD_EXE_FORMAT Code as follows: HINSTANCE hLib; hLib = LoadLibrary(_T(pszDll)); //STEP 2: un-register server if(hLib!=NULL) { PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllUnregisterServer")); if(pFunc!=NULL) { //Unregister the server! pFunc(); } else { //Additional exception handling here. dwError = GetLastError(); return 0; } } else { //Additional exception handling here. dwError = GetLastError(); return 0; } One last thing: When I build (Ctrl-F5) the ATL COM server project, I had no problem at all. THe server get registered, and I tested the server from VB client and it worked! Thanks! norm

          P Offline
          P Offline
          Peak
          wrote on last edited by
          #4

          hi have you tried this? nRetCode = WinExec("RegSvr32 /u \"C:\\Program Files\\RealTime7\\QueryGenAlpha\\QueryGenAlpha.dll\"", SW_SHOW);

          D 1 Reply Last reply
          0
          • P Peak

            hi have you tried this? nRetCode = WinExec("RegSvr32 /u \"C:\\Program Files\\RealTime7\\QueryGenAlpha\\QueryGenAlpha.dll\"", SW_SHOW);

            D Offline
            D Offline
            devvvy
            wrote on last edited by
            #5

            thanks for the feedback... i tried, and it worked just well: char szCommand[300]; for(i=0; i<300; i++) { szCommand[i]='\0'; } strcpy(szCommand, pszQueryGenDir); strcat(szCommand, "/RegSvr32.exe QueryGenAlpha.dll"); WinExec(szCommand, SW_SHOW); but RegSrv32 pop up is really annoying... I cant get LoadLibrary working unfortunately.. i'm suspecting that something is wrong with the function pointer: typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: It worked!!? //typedef void (*PFUNC) (void); //OPTION 2: It Does NOT WORK??? WHY???? Here's the code: int i = 0; DWORD dwErr = NULL; OleInitialize(NULL); typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: Requires stdole.h //typedef void (*PFUNC) (void); //OPTION 2: Wont work unfortunately. U wont even get a compiler/RT error. char * pszDll = NULL; pszDll = new char [300]; for(i=0; i<300; i++) { pszDll[i] = '\0'; } strcpy(pszDll, pszQueryGenDir); strcat(pszDll, "\\QueryGenAlpha.dll"); //STEP 1: Load dll. HINSTANCE hLib; hLib = LoadLibrary(_T(pszDll)); dwErr = GetLastError(); //STEP 2: register server if(hLib!=NULL) { PFUNC pFunc = NULL; pFunc = (PFUNC) GetProcAddress(hLib, _T("DllRegisterServer")); dwErr = GetLastError(); if(pFunc!=NULL) { //register the server! pFunc(); dwErr = GetLastError(); } else { //Additional exception handling here. FreeLibrary(hLib); return 0; } } else { //Additional exception handling here. return 0; } dwErr = GetLastError(); FreeLibrary(hLib); delete [] pszDll; OleUninitialize(); Thanks norm

            P 1 Reply Last reply
            0
            • D devvvy

              thanks for the feedback... i tried, and it worked just well: char szCommand[300]; for(i=0; i<300; i++) { szCommand[i]='\0'; } strcpy(szCommand, pszQueryGenDir); strcat(szCommand, "/RegSvr32.exe QueryGenAlpha.dll"); WinExec(szCommand, SW_SHOW); but RegSrv32 pop up is really annoying... I cant get LoadLibrary working unfortunately.. i'm suspecting that something is wrong with the function pointer: typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: It worked!!? //typedef void (*PFUNC) (void); //OPTION 2: It Does NOT WORK??? WHY???? Here's the code: int i = 0; DWORD dwErr = NULL; OleInitialize(NULL); typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: Requires stdole.h //typedef void (*PFUNC) (void); //OPTION 2: Wont work unfortunately. U wont even get a compiler/RT error. char * pszDll = NULL; pszDll = new char [300]; for(i=0; i<300; i++) { pszDll[i] = '\0'; } strcpy(pszDll, pszQueryGenDir); strcat(pszDll, "\\QueryGenAlpha.dll"); //STEP 1: Load dll. HINSTANCE hLib; hLib = LoadLibrary(_T(pszDll)); dwErr = GetLastError(); //STEP 2: register server if(hLib!=NULL) { PFUNC pFunc = NULL; pFunc = (PFUNC) GetProcAddress(hLib, _T("DllRegisterServer")); dwErr = GetLastError(); if(pFunc!=NULL) { //register the server! pFunc(); dwErr = GetLastError(); } else { //Additional exception handling here. FreeLibrary(hLib); return 0; } } else { //Additional exception handling here. return 0; } dwErr = GetLastError(); FreeLibrary(hLib); delete [] pszDll; OleUninitialize(); Thanks norm

              P Offline
              P Offline
              Peak
              wrote on last edited by
              #6

              hi have you traced the program execution? does it get to the pFunc() calling? does it come out of that call back to your program?

              D 1 Reply Last reply
              0
              • P Peak

                hi have you traced the program execution? does it get to the pFunc() calling? does it come out of that call back to your program?

                D Offline
                D Offline
                devvvy
                wrote on last edited by
                #7

                it did work, for whatever odd reason. all that i changed was the typedef, as i indicated earlier. i dont understand it. just followed as instructed. be nice if someone can give a bit of explanation though. norm

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups