CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2010
    Posts
    6

    [RESOLVED] Portability

    Hello Friends, I have the next problem.

    When I programm this simple application to generate a Window, I get an executable file. If I run the executable file on other computer, I get an error message "Can not find the component", "Didn't find the MSVCR100d.dll". Why can't I run the application on other computers? Thanks!!

    Code:
    #include "stdafx.h"
    #ifndef UNICODE
    #define UNICODE
    #endif 
    
    #include <windows.h>
    
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    
    int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
    {
        // Register the window class.
        const wchar_t CLASS_NAME[]  = L"Sample Window Class";
        
        WNDCLASS wc = { };
    
        wc.lpfnWndProc   = WindowProc;
        wc.hInstance     = hInstance;
        wc.lpszClassName = CLASS_NAME;
    
        RegisterClass(&wc);
    
        // Create the window.
    
        HWND hwnd = CreateWindowEx(
            0,                              // Optional window styles.
            CLASS_NAME,                     // Window class
            L"Learn to Program Windows",    // Window text
            WS_OVERLAPPEDWINDOW,            // Window style
    
            // Size and position
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
    
            NULL,       // Parent window    
            NULL,       // Menu
            hInstance,  // Instance handle
            NULL        // Additional application data
            );
    
        if (hwnd == NULL)
        {
            return 0;
        }
    
        ShowWindow(hwnd, nCmdShow);
    
        // Run the message loop.
    
        MSG msg = { };
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    
        return 0;
    }
    
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        switch (uMsg)
        {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    
        case WM_PAINT:
            {
                PAINTSTRUCT ps;
                HDC hdc = BeginPaint(hwnd, &ps);
    
                FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
    
                EndPaint(hwnd, &ps);
            }
            return 0;
    
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Portability

    It doesn't run because the computer where you run it does not have the required VC++ DLLs (in this case the C/C++ runtime, but it can also be MFC or ATL, depending on your app type). See this FAQ with links to redistributables to install on that machine: http://www.codeguru.com/forum/showthread.php?t=494136.

    However, notice that you are trying to run a Debug build. That won't work with the redistrituables from the above FAQ. You need to build and deploy a Release configuration.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Dec 2010
    Posts
    6

    Re: Portability

    Well, I have installed redistributable packages for VC++ Studio 2010. But it still don't work. I am working with Visual Studio C++ 2010 Express, and i don't know how to do it, and how to build and deploy a Release configuration.... Can you help me please?? Thanks!!

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Portability

    At the top in Visual Studio there is a dropdown box where you can select Debug and Release.
    Set that to Release and to a rebuild.
    It's against the EULA to distribute a Debug build of your applications.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Dec 2010
    Posts
    6

    Re: Portability

    Ok now it's works!!! sorry I am a beginner programming in Visual C++. Thank you very much!

  6. #6
    Join Date
    Dec 2010
    Posts
    6

    Re: [RESOLVED] Portability

    How I said, I'm new programming in visual studio. I have programming in C/C++ and Java in Linux, but I would like programming in Windows, Process and Drivers and so on. I am following the guide of msdn, http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx. Do you recommend me another guide?? Thanks you very much

  7. #7
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: [RESOLVED] Portability

    Quote Originally Posted by suizVisual View Post
    I am following the guide of msdn, http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx. Do you recommend me another guide??
    No. Maybe some books about Windows programming.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured