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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetprocAddress not able to locate address

GetprocAddress not able to locate address

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
12 Posts 2 Posters 0 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.
  • W With_problem

    i am trying to get address of dll function but not able to do that,any idea how to solve it..... it always return null....

    SetQuote = (Set_Quote_DB)GetProcAddress(hInstance,"setQuoteToDB");
    if(SetQuote != NULL)
    {

       MessageBox("set quote is not null");
     	
    }	
    else
    {
    	MessageBox("set quote is null");
    }
    
    H Offline
    H Offline
    Hamid Taebi
    wrote on last edited by
    #2

    Are you sure hInstance is valid ?


    WhiteSky


    W 1 Reply Last reply
    0
    • H Hamid Taebi

      Are you sure hInstance is valid ?


      WhiteSky


      W Offline
      W Offline
      With_problem
      wrote on last edited by
      #3

      yes i think ,see my code....

      HINSTANCE hInstance ;

      hInstance = AfxLoadLibrary("C:\\ActiveXdll\\WartzODLCOM.dll");
      if(hInstance != NULL)
      {
      //dont go further
      MessageBox("load dll");
      }
      else
      {
      MessageBox("enable to load dll");
      }

      //"GetProcAddress" get the address of the functions
      SetQuote = (Set_Quote_DB)GetProcAddress(hInstance,"setQuoteToDB");
      if(SetQuote != NULL)
      {

         MessageBox("set quote is not null");
       	
      }	
      else
      {
      	MessageBox("set quote is null");
      }
      
      H 1 Reply Last reply
      0
      • W With_problem

        yes i think ,see my code....

        HINSTANCE hInstance ;

        hInstance = AfxLoadLibrary("C:\\ActiveXdll\\WartzODLCOM.dll");
        if(hInstance != NULL)
        {
        //dont go further
        MessageBox("load dll");
        }
        else
        {
        MessageBox("enable to load dll");
        }

        //"GetProcAddress" get the address of the functions
        SetQuote = (Set_Quote_DB)GetProcAddress(hInstance,"setQuoteToDB");
        if(SetQuote != NULL)
        {

           MessageBox("set quote is not null");
         	
        }	
        else
        {
        	MessageBox("set quote is null");
        }
        
        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #4

        Did you use of GetLastError for error information?


        WhiteSky


        W 2 Replies Last reply
        0
        • H Hamid Taebi

          Did you use of GetLastError for error information?


          WhiteSky


          W Offline
          W Offline
          With_problem
          wrote on last edited by
          #5

          no

          H 1 Reply Last reply
          0
          • W With_problem

            no

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #6

            use of this function for see error and also check setQuoteToDB for exports statement on dll


            WhiteSky


            1 Reply Last reply
            0
            • H Hamid Taebi

              Did you use of GetLastError for error information?


              WhiteSky


              W Offline
              W Offline
              With_problem
              wrote on last edited by
              #7

              do you have any link,i have never used this function before

              H 2 Replies Last reply
              0
              • W With_problem

                do you have any link,i have never used this function before

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #8

                You dont need any link best explain is on MSDN :)


                WhiteSky


                1 Reply Last reply
                0
                • W With_problem

                  do you have any link,i have never used this function before

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #9

                  Is your problem solving?


                  WhiteSky


                  W 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    Is your problem solving?


                    WhiteSky


                    W Offline
                    W Offline
                    With_problem
                    wrote on last edited by
                    #10

                    No i am still stuck with same problem...do you have any clear idea how to call com dll function....i think my problem is that only....pls if you can help me....

                    H 1 Reply Last reply
                    0
                    • W With_problem

                      No i am still stuck with same problem...do you have any clear idea how to call com dll function....i think my problem is that only....pls if you can help me....

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #11

                      Check name function and parameters(input/output) on dll that are same with when you call this file on your application


                      WhiteSky


                      W 1 Reply Last reply
                      0
                      • H Hamid Taebi

                        Check name function and parameters(input/output) on dll that are same with when you call this file on your application


                        WhiteSky


                        W Offline
                        W Offline
                        With_problem
                        wrote on last edited by
                        #12

                        see i have chkge the code still i am not able to locate my function.....i have tried all my best...pls help me...still it return null...and for function call setquotetodb is....unhandled exeption in apiocx access violation. code here

                        HRESULT hresult;
                        CLSID clsid;
                        
                        CoInitialize(NULL);
                        hresult=CLSIDFromProgID(OLESTR("WartzODLCOM.DBAccess"),&clsid);
                        \_DBAccess \*t;
                        hresult=CoCreateInstance(clsid,NULL,CLSCTX\_INPROC\_SERVER,\_\_uuidof(IDispatch ),(LPVOID \*) &t);
                        
                        if(FAILED(hresult))
                        {
                        AfxMessageBox("Creation Failed");
                        return;
                        }
                        
                        else
                        {
                        MessageBox("success");
                        }
                        
                        SessID=SessionId;
                        CurrentRequestId=RequestId;
                        
                        marketno.Format("%d",MarketNo);
                        bid\_d.Format("%c",BidDirection);
                        ask\_d.Format("%c",AskDirection);
                        marketstate.Format("%d",MarketState);
                        
                           m\_MainEdit= SessionId + "\\t" + RequestId +"\\t"+ marketno ; 
                        m\_MainEdit= Market + Bid  + bid\_d +  Ask +ask\_d High ;
                        m\_MainEdit=m\_MainEdit + Low  + marketstate   + Timestamp ;
                        
                        UpdateData(FALSE);
                        iLineCount=m\_EditCtrl.GetLineCount();
                        m\_EditCtrl.LineScroll(iLineCount);
                        

                        if(hresult != NULL)
                        {
                        MessageBox("not null");
                        USES_CONVERSION;
                        BSTR bsTimeStamp = A2BSTR(Timestamp);
                        BSTR bsMarket = A2BSTR(Market);
                        BSTR bsBid = A2BSTR(Bid);
                        BSTR bsAsk = A2BSTR(Ask);

                        // SetQuote(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
                        t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
                        SysFreeString(bsTimeStamp);
                        SysFreeString(bsMarket);
                        SysFreeString(bsBid);
                        SysFreeString(bsAsk);
                        }
                        else
                        {
                        MessageBox("null");
                        }
                        // FreeLibrary( hInstance );

                        CoUninitialize();
                        
                        return;
                        }
                        
                        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