Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

Deflation Animation not Working

$
0
0

Hi,

I have got a code from this forum which create a ellipse on the client area. First it creates a rectangle equivalent to the size of client area. I have put the deflation code in the ::OnTimer( ....) but its not working.

void CTestingCode1View::OnDraw(CDC* pDC) { CTestingCode1Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; GetClientRect(&rect); //CRect rc(rect.TopLeft().x+10, rect.TopLeft().y+10,rect.BottomRight().x-10,rect.BottomRight().y-10); //CDC *pDC = GetDC(); CDC WorkDC; CBitmap memBmp, * pOldMemBmp; WorkDC.CreateCompatibleDC(pDC); memBmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); pOldMemBmp = (CBitmap *)WorkDC.SelectObject(&memBmp); int oldBkMode = WorkDC.SetBkMode(TRANSPARENT); WorkDC.Ellipse(rect); WorkDC.SetBkMode(oldBkMode); // WorkDC.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY); //pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &WorkDC, 0, 0, SRCCOPY); pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &WorkDC, 0, 0, SRCCOPY); WorkDC.SelectObject(pOldMemBmp); pOldMemBmp->DeleteObject(); // TODO: add draw code for native data here }

void CTestingCode1View::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
rect.DeflateRect(10,10);
CView::OnTimer(nIDEvent);
}


int CTestingCode1View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
SetTimer(1,200,NULL);
//#3016

//@R0
//return -1;

//#3016

//@R0

//#3016

//@R0
// TODO:  Add your specialized creation code here

//@R0
return 0;
}

CReact is declared as a class variable in *view.h. Some body please guide me.

Zulfi.


why wont they declare?

$
0
0

#include <fstream>
#include <iostream>
#include <string>
#include "std_lib_facilities.h"
using namespace std;


int main()
{
int serial_julian_date(int Month, int Day, int Year);
int nDate;
int a = (14 - Month) / 12;
int m = Month + (12 * a) - 3;
int y = (Year+ (4800 - a));
nDate = Day+ (((153 * m) + 2) / 5) + (365 * y) + (y / 4) - (y / 100) + (y / 400) - 32045;
cin >> nDate;
cout << "Enter a date in MM DD YYYY format(separated by spaces): \n";
system("pause");

}

i cant seem to get the bolded words to initialize 

Stubborn Unresolved External Symbol Problem.

$
0
0

Hello Folks:

   Developing on Win8.1 Pro, Visual Studio 2010, C++, WIN32 no MFC.  

   Here is a weird one.  I must be doing something really stupid.  

   I've been adding code to a massive project for years.  It was 100,000 lines of code when I checked a couple of years ago, and is growing.  

   The application's static library has over 200 ".cpp" source files, not counting the headers.  It also relies upon a similar number of source modules from static libraries used by other applications.  

   Yesterday builds started generating this error, formatted to make it easier to understand:

3>tfa.obj : error LNK2019: unresolved external symbol "
         bool __cdecl run_contact_import_from_menu(
                                struct HWND__ *,
                                struct HWND__ *,
                                class PROCESS_RECORD *,
                                class TFA_THREAD_CRYPTO_RECORD *,
                                class TFA_THREAD_CRYPTO_RECORD *,
                                class botan_utilities::EAX_CTR_THREAD_CRYPTO_RECORD *,
                                class TFA_MAIN_WINDOW_CONTEXT *,
                                class std::basic_string<char,
                                      struct std::char_traits<char>,
                                                 class std::allocator<char> > *)"

   I tried a few things.  When I commented out the call to run_contact_import_from_menu() the application built without a problem.  

   I wasn't even working on that part of the application.  

The usual solution:

   I've seen unresolved external symbol errors before of course.  It usually means I've changed the function's arguments without updating the function's forward declaration in a header, and I haven't updated a call to the function elsewhere in the code.  The first thing I did was copy the interface from the function's definition in a "cpp" file:

bool run_contact_import_from_menu(HWND hdlg,
                       HWND change_alert_source_window_handle,
                       PROCESS_RECORD *process_record_ptr,
                       TFA_THREAD_CRYPTO_RECORD *tfa_thread_crypto_ptr,
                       TFA_THREAD_CRYPTO_RECORD *tfa_thread_financial_crypto_ptr,
                       EMAIL_THREAD_CRYPTO_RECORD *tfa_thread_email_crypto_record_ptr,
                       TFA_MAIN_WINDOW_CONTEXT *main_window_dialog_context_ptr,
                                                      std::string *message_string_ptr)
replaced it in the header file, and added a ";" to make it a forward declaration.  


   Same error.  

   EMAIL_THREAD_CRYPTO_RECORD is botan_utilities::EAX_CTR_THREAD_CRYPTO_RECORD:

   From the email thread's header:

      typedef botan_utilities::EAX_CTR_THREAD_CRYPTO_RECORD EMAIL_THREAD_CRYPTO_RECORD;

   For testing, I slapped that typedef in front of the function's forward declaration and the function's definition.  Compiles fine, same link error.  

This seems to be the only unresolved external

   After #ifdef-ing out the call to this function, this application with it's thousands of calls to thousands of different functions built just fine, and ran as expected.  

Is the module's C++ file being processed?

   This function isn't being found in tfa_contact_import.cpp, where it lives.  What happens when I comment out other function definitions in this C++ file?  

   Now I get a whole bunch of "error LNK2019: unresolved external symbol" errors.  Other functions in that file are being referenced, and found.  And missed if they are absent.  

   Is it positional?  run_contact_import_from_menu() is the first function defined in the file.  Moving it to the end of the file gets me the same error.  

   I create a new C++ file with the "Add New Item" to the app's library, just for this function.  Same error.  

   I change the function's name to "run_contact_import_from_menu_x".  New name, same error.  

   I'm missing something really basic, really obvious.  Can someone tell me what it is?  

      Thanks
      Larry


WTSVirtualChannelOpen fails with ERROR_NOT_SUPPORTED on Windows 2012 R2

$
0
0

Hi,

I am testing this simple C++ application below on Windows 2012 R2 and WTSVirtualChannelOpen fails with error code "ERROR_NOT_SUPPORTED". The same application runs fine on Windows Server 2008.

I have tried with WTSVirtualChannelOpenEx but I got the same error code.

Can anyone help me shed some light on this issue? That would be much appreciated :-)

Thank you.

#include <conio.h>
#include <windows.h>
#include <Wtsapi32.h>
#include <iostream>

#define TERMINAL_SERVICES_VC_NAME "TEST"

int _tmain(int argc, _TCHAR* argv[])
{
	std::cout << "<< Virtual Channel App >>" << std::endl;
	HANDLE hVirtualChannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, TERMINAL_SERVICES_VC_NAME);

	if(hVirtualChannel)
		std::cout << "WTSVirtualChannelOpen successful" << std::endl;
	else
		std::cerr << "WTSVirtualChannelOpen fails with error code: " << GetLastError() << std::endl;

	std::cout << "Press Enter to quit..." << std::endl;
	_getch();

	if(WTSVirtualChannelClose(hVirtualChannel))
		std::cout << "TSVirtualChannelClose successful" << std::endl;
	else
		std::cerr << "TSVirtualChannelClose fails with error code: " << GetLastError() << std::endl;
	return 0;
}

Lowest Level Call X64 and what need to be preserved?

$
0
0

Hi, 

Our team- recently had a problem regarding a lowest level function in x64 bit machines in Windows - and what needs to be preserved in order to safely handle the event and pass it on to Windows Kernel. I am not too experienced in handling functions this deep into Usermode (Ring3). 

Can someone please answer my doubts? 

Thanks

Syntax errors in old C++ code

$
0
0

The following code is from an old C++ program that worked under old versions of Windows

int FAR PASCAL _export NewFrameNameDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam)

but now generates syntax errors as follows

Error1067 error C2061: syntax error : identifier 'NewFrameNameDlg'
Error1068 error C2059: syntax error : ';'
Error1069 error C2059: syntax error : 'type'

Any idea why?

CreateProcessAsUser from Local System Admin does not apply Windows style

$
0
0

Hi, i have a problem in an application using Windows API CreateProcessAsUser from local system admin in order to run an application as a different user. Everything works fine so far, but the Windows window and frame style are not applied somehow. The window always looks like a Windows 2000 window with huge frames. I also attached some screenshot:

<image missing due to the verify account restrictions>

I also wrote some example code of how we do all the magic in C++ without taking care of handles and stuff.

Just make sure that you have locally some user "test" with password "test" set and try to run the posted source code as local system administrator. Other user will cause an error code 1413 if you try to execute the code.

The problem occurres mainly on Windows 7 VMs in VirtualBox, on some Windows 7 systems and on all Windows 8.1 systems. Very strange. Can anyone help me to solve this problem? Thanks!

#include <iostream>
#include <Windows.h>
#include <UserEnv.h>
#include <WinWlx.h>

int AddAceToWindowStation( HWINSTA  hwinsta, PSID psid )
{
    DWORD lengthNeeded;

    SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
    if( !GetUserObjectSecurity( hwinsta, &secInfo, NULL, NULL, &lengthNeeded ) )
    {
        if ( GetLastError() != 122 )
        {
            std::cout << "GetUserObjectSecurity1 error: " << GetLastError() << std::endl;
            return 0;
        }
    }

    PSECURITY_DESCRIPTOR pSecDescriptor = ( PSECURITY_DESCRIPTOR ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        lengthNeeded );

    if ( pSecDescriptor == NULL )
    {
        std::cout << "Allocating memory for pSecDescriptor failed: " << GetLastError() << std::endl;
        return 0;
    }

    PSECURITY_DESCRIPTOR pSecDescriptorNew = ( PSECURITY_DESCRIPTOR ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        lengthNeeded );

    if ( pSecDescriptorNew == NULL )
    {
        std::cout << "Allocating memory for pSecDescriptorNew failed: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !GetUserObjectSecurity( hwinsta, &secInfo, pSecDescriptor, lengthNeeded, &lengthNeeded ) )
    {
        std::cout << "GetUserObjectSecurity2 error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !InitializeSecurityDescriptor( pSecDescriptorNew, SECURITY_DESCRIPTOR_REVISION ) )
    {
        std::cout << "InitializeSecurityDescriptor error: " << GetLastError() << std::endl;
        return 0;
    }

    BOOL DaclPresent;
    PACL pOldDacl;
    BOOL DaclDefaulted;
    if ( !GetSecurityDescriptorDacl( pSecDescriptor, &DaclPresent, &pOldDacl, &DaclDefaulted ) )
    {
        std::cout << "GetSecurityDescriptorDacl error: " << GetLastError() << std::endl;
        return 0;
    }

    // Get size information for DACL
    ACL_SIZE_INFORMATION AclInfo;
    AclInfo.AceCount = 0; // Assume NULL DACL.
    AclInfo.AclBytesFree = 0;
    AclInfo.AclBytesInUse = sizeof( ACL );

    if ( pOldDacl == NULL )
        DaclPresent = FALSE;

    // If not NULL DACL, gather size information from DACL.
    if ( DaclPresent )
    {
        if ( !GetAclInformation( pOldDacl, &AclInfo,
            sizeof( ACL_SIZE_INFORMATION ), AclSizeInformation ) )
        {
            std::cout << "GetAclInformation error: " << GetLastError() << std::endl;
            return 0;
        }
    }

    DWORD cbNewACL = AclInfo.AclBytesInUse + sizeof( ACCESS_ALLOWED_ACE ) + sizeof( ACL ) + sizeof( ACL ) + sizeof( ACCESS_ALLOWED_ACE ) + sizeof( ACL ) + sizeof( ACL );

    PACL pNewACL = ( PACL ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        cbNewACL );

    if ( !InitializeAcl( pNewACL, cbNewACL, ACL_REVISION ) )
    {
        std::cout << "InitializeAcl error: " << GetLastError() << std::endl;
        return 0;
    }

    LPVOID         pTempAce = NULL;

    // Copy old Ace to new DACL
    if ( DaclPresent && AclInfo.AceCount )
    {
        std::cout << "AclInfo.AceCount:" << AclInfo.AceCount << std::endl;
        for ( int i = 0; i < AclInfo.AceCount; ++i )
        {
            if ( !GetAce( pOldDacl, i, &pTempAce ) )
            {
                std::cout << "GetAce[" << i << "] error: " << GetLastError() << std::endl;
                return 0;
            }

            if ( !AddAce( pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
                ( ( PACE_HEADER ) pTempAce )->AceSize ) )
            {
                std::cout << "AddAce[" << i << "] error: " << GetLastError() << std::endl;
                return 0;
            }
        }
    }

    if ( !AddAccessAllowedAceEx( pNewACL, ACL_REVISION, CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE | OBJECT_INHERIT_ACE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL, psid ) )
    {
        std::cout << "AddAccessAllowedAceEx1 error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !AddAccessAllowedAceEx( pNewACL, ACL_REVISION, NO_PROPAGATE_INHERIT_ACE, WINSTA_ENUMDESKTOPS | WINSTA_READATTRIBUTES | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS | WINSTA_ENUMERATE | WINSTA_READSCREEN | STANDARD_RIGHTS_REQUIRED, psid ) )
    {
        std::cout << "AddAccessAllowedAceEx2 error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !SetSecurityDescriptorDacl( pSecDescriptorNew, TRUE, pNewACL, FALSE ) )
    {
        std::cout << "SetSecurityDescriptorDacl error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !SetUserObjectSecurity( hwinsta, &secInfo, pSecDescriptorNew ) )
    {
        std::cout << "SetUserObjectSecurity error: " << GetLastError() << std::endl;
        return 0;
    }

    return 1;
}

int AddAceToDesktop( HDESK  hdesk, PSID psid )
{
    DWORD lengthNeeded;

    SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
    if ( !GetUserObjectSecurity( hdesk, &secInfo, NULL, NULL, &lengthNeeded ) )
    {
        if ( GetLastError() != 122 )
        {
            std::cout << "GetUserObjectSecurity1 error: " << GetLastError() << std::endl;
            return 0;
        }
    }

    PSECURITY_DESCRIPTOR pSecDescriptor = ( PSECURITY_DESCRIPTOR ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        lengthNeeded );

    if ( pSecDescriptor == NULL )
    {
        std::cout << "Allocating memory for pSecDescriptor failed: " << GetLastError() << std::endl;
        return 0;
    }

    PSECURITY_DESCRIPTOR pSecDescriptorNew = ( PSECURITY_DESCRIPTOR ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        lengthNeeded );

    if ( pSecDescriptorNew == NULL )
    {
        std::cout << "Allocating memory for pSecDescriptorNew failed: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !GetUserObjectSecurity( hdesk, &secInfo, pSecDescriptor, lengthNeeded, &lengthNeeded ) )
    {
        std::cout << "GetUserObjectSecurity2 error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !InitializeSecurityDescriptor( pSecDescriptorNew, SECURITY_DESCRIPTOR_REVISION ) )
    {
        std::cout << "InitializeSecurityDescriptor error: " << GetLastError() << std::endl;
        return 0;
    }

    BOOL DaclPresent;
    PACL pOldDacl;
    BOOL DaclDefaulted;
    if ( !GetSecurityDescriptorDacl( pSecDescriptor, &DaclPresent, &pOldDacl, &DaclDefaulted ) )
    {
        std::cout << "GetSecurityDescriptorDacl error: " << GetLastError() << std::endl;
        return 0;
    }

    // Get size information for DACL
    ACL_SIZE_INFORMATION AclInfo;
    AclInfo.AceCount = 0; // Assume NULL DACL.
    AclInfo.AclBytesFree = 0;
    AclInfo.AclBytesInUse = sizeof( ACL );

    if ( pOldDacl == NULL )
        DaclPresent = FALSE;

    // If not NULL DACL, gather size information from DACL.
    if ( DaclPresent )
    {
        if ( !GetAclInformation( pOldDacl, &AclInfo,
            sizeof( ACL_SIZE_INFORMATION ), AclSizeInformation ) )
        {
            std::cout << "GetAclInformation error: " << GetLastError() << std::endl;
            return 0;
        }
    }

    DWORD cbNewACL = AclInfo.AclBytesInUse + sizeof( ACCESS_ALLOWED_ACE ) + sizeof( ACL ) + sizeof( ACL );

    PACL pNewACL = ( PACL ) HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        cbNewACL );

    if ( !InitializeAcl( pNewACL, cbNewACL, ACL_REVISION ) )
    {
        std::cout << "InitializeAcl error: " << GetLastError() << std::endl;
        return 0;
    }

    LPVOID         pTempAce = NULL;

    // Copy old Ace to new DACL
    if ( DaclPresent && AclInfo.AceCount )
    {
        std::cout << "AclInfo.AceCount:" << AclInfo.AceCount << std::endl;
        for ( int i = 0; i < AclInfo.AceCount; ++i )
        {
            if ( !GetAce( pOldDacl, i, &pTempAce ) )
            {
                std::cout << "GetAce[" << i << "] error: " << GetLastError() << std::endl;
                return 0;
            }

            if ( !AddAce( pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
                ( ( PACE_HEADER ) pTempAce )->AceSize ) )
            {
                std::cout << "AddAce[" << i << "] error: " << GetLastError() << std::endl;
                return 0;
            }
        }
    }

    if ( !AddAccessAllowedAce( pNewACL, ACL_REVISION, DESKTOP_READOBJECTS | DESKTOP_CREATEWINDOW | DESKTOP_CREATEMENU | DESKTOP_HOOKCONTROL | DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK | DESKTOP_ENUMERATE | DESKTOP_WRITEOBJECTS | DESKTOP_SWITCHDESKTOP | STANDARD_RIGHTS_REQUIRED, psid ) )
    {
        std::cout << "AddAccessAllowedAce error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !SetSecurityDescriptorDacl( pSecDescriptorNew, TRUE, pNewACL, FALSE ) )
    {
        std::cout << "SetSecurityDescriptorDacl error: " << GetLastError() << std::endl;
        return 0;
    }

    if ( !SetUserObjectSecurity( hdesk, &secInfo, pSecDescriptorNew ) )
    {
        std::cout << "SetUserObjectSecurity error: " << GetLastError() << std::endl;
        return 0;
    }

    return 1;
}

int AddAceToBaseNameObjectsDirectory( PSID psid, TOKEN_INFORMATION_CLASS tClass )
{
    return 0;
}

int main( int argc, TCHAR *argv[] )
{
    HANDLE userToken;

    if ( !LogonUser( L"test", L"", L"test", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &userToken ) )
    {
        std::cout << "LogonUser error: " << GetLastError() << std::endl;
        return -1;
    }

    HANDLE token;

    if ( !DuplicateTokenEx( userToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &token ) )
    {
        std::cout << "DuplicateTokenEx error: " << GetLastError() << std::endl;
        return -1;
    }

    PROFILEINFO profileInfo;
    profileInfo.lpUserName = L"test";
    profileInfo.dwFlags = NULL;
    profileInfo.lpProfilePath = L"C:\\Users\\test";

    LoadUserProfile( token, &profileInfo );

    LUID tcb_privilege_flag;

    if ( !LookupPrivilegeValue( NULL, SE_SECURITY_NAME, &tcb_privilege_flag ) )
    {
        std::cout << "LookupPrivilegeValue error: " << GetLastError() << std::endl;
        return -1;
    }

    TOKEN_PRIVILEGES tp;

    tp.PrivilegeCount = 1;
    tp.Privileges[0].Luid = tcb_privilege_flag;
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

    if ( !AdjustTokenPrivileges( token, FALSE, &tp, sizeof( TOKEN_PRIVILEGES ), ( PTOKEN_PRIVILEGES ) NULL, ( PDWORD ) NULL ) )
    {
        std::cout << "AdjustTokenPrivileges error: " << GetLastError() << std::endl;
        return -1;
    }

    HWINSTA hwinstasave = GetProcessWindowStation();
    HWINSTA hwinsta = OpenWindowStation( L"winsta0", FALSE, READ_CONTROL | WRITE_DAC );

    HDESK hdesk = OpenDesktop( L"default", NULL, FALSE, READ_CONTROL | WRITE_DAC | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS );

    DWORD token_group_size;

    if ( !GetTokenInformation( token, TokenGroups, NULL, 0, &token_group_size ) )
    {
        if ( GetLastError() != 122 )
        {
            std::cout << "GetTokenInformation1 error: " << GetLastError() << std::endl;
            return -1;
        }
    }

    PTOKEN_GROUPS pTokenGroup = ( PTOKEN_GROUPS ) new BYTE[token_group_size];
    memset( pTokenGroup, 0, token_group_size );

    if ( !GetTokenInformation( token, TokenGroups, pTokenGroup, token_group_size, &token_group_size ) )
    {
        std::cout << "GetTokenInformation2 error: " << GetLastError() << std::endl;
        return -1;
    }

    PSID pSid = NULL;
    for ( int i = 0; i < pTokenGroup->GroupCount; ++i )
    {
        if ( ( pTokenGroup->Groups[i].Attributes & SE_GROUP_LOGON_ID ) == SE_GROUP_LOGON_ID )
        {
            pSid = pTokenGroup->Groups[i].Sid;
        }
    }

    if ( pSid == NULL )
    {
        std::cout << "Unable to get logonSID error! No entry found!!!" << std::endl;
        return -1;
    }

    if ( !AddAceToWindowStation( hwinsta, pSid ) )
    {
        std::cout << "AddAceToWindowStation error: " << GetLastError() << std::endl;
        return -1;
    }

    if ( !AddAceToDesktop( hdesk, pSid ) )
    {
        std::cout << "AddAceToDesktop error: " << GetLastError() << std::endl;
        return -1;
    }

    //if ( !AddAceToBaseNameObjectsDirectory( pSid, TokenSessionId ) )
    //{
    //  std::cout << "AddAceToBaseNameObjectsDirectory error: " << GetLastError() << std::endl;
    //  return -1;
    //}

    if ( !ImpersonateLoggedOnUser( token ) )
    {
        std::cout << "ImpersonateLoggedOnUser error: " << GetLastError() << std::endl;
        return -1;
    }

    STARTUPINFO startupInfo;

    memset( &startupInfo, 0, sizeof( startupInfo ) );

    startupInfo.dwFlags = STARTF_USESHOWWINDOW;
    startupInfo.wShowWindow = SW_SHOWNORMAL;
    startupInfo.lpDesktop = L"winsta0\\default";
    startupInfo.cb = sizeof( startupInfo );

    PROCESS_INFORMATION procInfo;

    memset( &procInfo, 0, sizeof( procInfo ) );

    if ( !SetCurrentDirectory( L"C:\\Windows" ) )
    {
        std::cout << "SetCurrentDirectory error: " << GetLastError() << std::endl;
        return -1;
    }

    if ( !CreateProcessAsUserW( token, L"Notepad.exe", L"Notepad.exe", NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startupInfo, &procInfo ) )
    {
        std::cout << "CreateProcessAsUser error: " << GetLastError() << std::endl;
        return -1;
    }

    if ( !WaitForSingleObject( token, INFINITE ) )
    {
        std::cout << "WaitForSingleObject error: " << GetLastError() << std::endl;
        return -1;
    }
}

AriaDebugVC10.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0

$
0
0

When i try to compile a program with Visual Studio 2012 i get the error above, i can use the AriaDebugVC10.dll with other solutions and it creates the exe perfectly fine.

how can i fix this?

1>------ Build started: Project: labs6_and_7, Configuration: Debug Win32 ------
1>AriaDebugVC10.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

log file shows

Build started 08/02/2015 19:30:34.
     1>Project "C:\PATH TO SOLUTION\labs6_and_7\labs6_and_7.vcxproj" on node 2 (Build target(s)).
     1>Link:
         C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\PATH TO SOLUTION\labs6_and_7\Debug\labs6_and_7.exe" /INCREMENTAL /NOLOGO AriaDebugVC10.dll kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\PATH TO SOLUTION\labs6_and_7.pdb" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\PATH TO SOLUTION\labs6_and_7\Debug\labs6_and_7.lib" /MACHINE:X86 Debug\wanderAndAvoid.obj
         Debug\main.obj
     1>AriaDebugVC10.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0
     1>Done Building Project "C:\PATH TO SOLUTION\labs6_and_7\labs6_and_7.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:00.67


Need help in running this code!!

$
0
0

https://cs.senecac.on.ca/~gam670/pages/content/force.html

This website provides sample code for forced feedback joystick. I wanted to try it with my Logitech Force 3D pro joystick. I used MS Visual studio professional 2013 to run the code, but I am getting errors. Looks like I am missing somethings.

Can someone please help me in running these codes?

console error : is not recognized as an internal or external command, operable program or batch file.

$
0
0

i was making this small program with the use of random numbers and when i built it without the console (control+F7) it had succeeded but when i tried to use it with the console (control+F5) the following error below kept appearing, how can i fix this??

i also tried it with this program and the same thing happened

Add Controls to Window

$
0
0

Hi,

I am creating my first Win32 ATL application. I have found that I'm provided with a main window by default. The window has a menu bar on it. I am trying to figure out how to add Active X controls to this window. I can create a new dialog and add controls to the new dialog via the toolbox, but I'm not able to access the main window during design time at all.

Does anyone have any examples of how this is done?

Also, is there a dedicated C++ board for Win32 ATL? I haven't been able to find one on MSDN.

Thanks!

Surface pro pen caused application hang

$
0
0

Hi All,

I was do the products migrating from desktop to surface and other tablets that support Windows OS. 

Our product was implemented MFC & ATL, the main product worked as container, then the sub process was launched.

        When try to close the sub-process, it will popup a modal-dialog. If the modal-dialog was issued via surface pen, the application will hang. It works fine if click by hand from touch screen or by mouse clicking.

The main process's UI thread:

0:000> !wow64exts.sw
Switched to 32bit mode
0:000:x86> kv fff
  Memory  ChildEBP RetAddr  Args to Child
          0018dd60 76d30927 00000002 0018df0c 00000001 ntdll_77b40000!ZwWaitForMultipleObjects+0xc (FPO: [5,0,0])
      184 0018dee4 776bb6e5 0018debc 0018df0c 00000000 KERNELBASE!WaitForMultipleObjectsEx+0xcc (FPO: [SEH])
       58 0018df3c 7796c1db 00000000 0018df94 000003e8 user32!MsgWaitForMultipleObjectsEx+0x159 (FPO: [Non-Fpo])
       34 0018df70 77a33271 0018df94 00000001 0018df9c combase!CCliModalLoop::BlockFn+0x101 (FPO: [Non-Fpo]) (CONV: thiscall) [d:\blue_gdr\com\combase\dcomrem\callctrl.cxx @ 1571]
       6c 0018dfdc 77a316cd 0018e27c 0ec9f2e4 090dc4b0 combase!ThreadSendReceive+0x1d3 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\channelb.cxx @ 5776]
      148 0018e124 7796c6ac 0ec9f2e4 0018e27c 0018e264 combase!CRpcChannelBuffer::SendReceive2+0x1df (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\channelb.cxx @ 4796]
       c0 0018e1e4 77933b8f 0ec9f2e4 0018e27c 0018e264 combase!ClassicSTAThreadSendReceive+0x209 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\callctrl.cxx @ 696]
       5c 0018e240 77a314a5 0ec9f2e4 0018e27c 0018e264 combase!CCtxComChnl::SendReceive+0xf9 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\ctxchnl.cxx @ 790]
       18 0018e258 75995ee5 0eb32fbc 0018e2a8 75a0e9d0 combase!NdrExtpProxySendReceive+0x42 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\ndr\ndrole\proxy.cxx @ 2017]
        c 0018e264 75a0e9d0 379b6970 0018ea38 0018ea14 rpcrt4!NdrpProxySendReceive+0xe (FPO: [0,0,0])
      440 0018e6a4 75aa1a9c 75a798c0 75a7e87a 0018e6c4 rpcrt4!NdrClientCall2+0x2d6 (FPO: [SEH])
       18 0018e6bc 75aa1a4d 0eb32fbc ffffff91 74eb5f88 oleaut32!IDispatch_RemoteInvoke_Proxy+0x24 (FPO: [12,1,0])
      2dc 0018e998 74f711d6 0eb32fbc ffffff91 74eb5f88 oleaut32!IDispatch_Invoke_Proxy+0xf1 (FPO: [Non-Fpo])
       d0 0018ea68 74f71527 ffffff91 00000001 0000000b mfc90u!COleDispatchDriver::InvokeHelperV+0x324
       20 0018ea88 00411f6a 0f1dfff8 ffffff91 00000001 mfc90u!COleDispatchDriver::InvokeHelper+0x20
       9c 0018eb24 0042669d 0f1dff28 0018eb8c 004226b4 VStudio!AOADispDriver::Close+0xea (FPO: [Non-Fpo]) (CONV: thiscall)
        c 0018eb30 004226b4 427fc568 00020462 0018eb24 VStudio!PrjCntrItem::CloseComponent+0x2d (FPO: [Non-Fpo]) (CONV: thiscall)
       5c 0018eb8c 74f3dcbf 0396c360 00000000 0018ebb4 VStudio!PrjContainerDoc::SaveModified+0x104 (FPO: [Non-Fpo]) (CONV: thiscall)
       10 0018eb9c 74f15180 0f7b7420 74f1514e 00000000 mfc90u!CDocument::CanCloseFrame+0x41
       18 0018ebb4 74f0fb03 3700a788 00000010 0f7b7420 mfc90u!CFrameWnd::OnClose+0x32
       a4 0018ec58 74f0f6cc 00000010 00000000 00000000 mfc90u!CWnd::OnWndMsg+0x410
       20 0018ec78 74f0e2f2 00000010 00000000 00000000 mfc90u!CWnd::WindowProc+0x24
       68 0018ece0 74f0e57e 00000000 00050520 00000010 mfc90u!AfxCallWndProc+0xa3
       24 0018ed04 74f0c234 00050520 00000010 00000000 mfc90u!AfxWndProc+0x37
       48 0018ed4c 776b791c 00050520 00000010 00000000 mfc90u!AfxWndProcBase+0x56
       2c 0018ed78 776b7b7a 74f0c1de 00050520 00000010 user32!_InternalCallWinProc+0x23
       90 0018ee08 776bc7be 74f0c1de 00000000 00000010 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       38 0018ee40 778ae02c 74f0c1de 00050520 00000010 user32!CallWindowProcW+0x83 (FPO: [Non-Fpo])
       50 0018ee90 778ae4b0 00000010 00000000 00000000 ole32!CFrameFilter::OnMessage+0x88 (FPO: [Non-Fpo]) (CONV: thiscall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 2146]
       1c 0018eeac 776b791c 00050520 00000010 00000000 ole32!FrameWndFilterProc+0x6a (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 1159]
       2c 0018eed8 776b7b7a 778ae446 00050520 00000010 user32!_InternalCallWinProc+0x23
       90 0018ef68 776b7ccd 778ae446 00000000 00000010 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       60 0018efc8 776b7e23 009606b0 00000000 00000010 user32!DispatchClientMessage+0xdc (FPO: [Non-Fpo])
       38 0018f000 77b7c692 0018f018 00000000 0018f260 user32!__fnDWORD+0x36 (FPO: [1,6,0])
       34 0018f034 776bad43 00050520 00000112 0000f060 ntdll_77b40000!KiUserCallbackDispatcher+0x2e (FPO: [0,0,0])
       90 0018f0c4 776ba0ab 009606b0 00000000 009b0337 user32!RealDefWindowProcWorker+0x13f (FPO: [Non-Fpo])
       18 0018f0dc 74881814 00050520 00000112 0000f060 user32!RealDefWindowProcW+0x53 (FPO: [Non-Fpo])
       14 0018f0f0 748aac55 01ce2db8 0018f210 748817aa uxtheme!DoMsgDefault+0x21 (FPO: [0,0,0])
        c 0018f0fc 748817aa 01ce2db8 0018f1a4 7772e280 uxtheme!OnDwpSysCommand+0x2a (FPO: [Non-Fpo])
      114 0018f210 74881ddf 0000f060 009b0337 00000001 uxtheme!_ThemeDefWindowProc+0x755 (FPO: [Non-Fpo])
       14 0018f224 776ba042 00050520 00000112 0000f060 uxtheme!ThemeDefWindowProcW+0x18 (FPO: [4,0,0])
       4c 0018f270 776e3bbb 00050520 00000112 0000f060 user32!DefWindowProcW+0x158 (FPO: [SEH])
       3c 0018f2ac 776d5782 0000f060 009b0337 00000000 user32!DefMDIChildProcWorker+0xe79a
       14 0018f2c0 74f18c87 00050520 00000112 0000f060 user32!DefMDIChildProcW+0x18 (FPO: [4,0,0])
       18 0018f2d8 4c0e215a 00000112 0000f060 009b0337 mfc90u!CMDIChildWnd::DefWindowProcW+0x17
       2c 0018f304 74f0e3c1 00000000 0000f060 009b0337 ot1101asu!SECMDIChildWnd::DefWindowProcW+0x12a (FPO: [3,3,0]) (CONV: thiscall) [c:\program files\rogue wave\stingray studio 10.1\src\toolkit\mdi\swinmdi.cpp @ 4177]
       14 0018f318 74f15604 0f7b7420 00432250 0018f33c mfc90u!CWnd::Default+0x30 (FPO: [0,0,1])
       10 0018f328 00432267 0000f060 009b0337 0f7b7420 mfc90u!CFrameWnd::OnSysCommand+0x50
       14 0018f33c 74f0fd15 0000f060 009b0337 3700bf18 VStudio!PrjMDIChild::OnSysCommand+0x17 (FPO: [Non-Fpo]) (CONV: thiscall)
       ac 0018f3e8 74f0f6cc 00000112 0000f060 009b0337 mfc90u!CWnd::OnWndMsg+0x622
       20 0018f408 74f0e2f2 00000112 0000f060 009b0337 mfc90u!CWnd::WindowProc+0x24
       68 0018f470 74f0e57e 00000000 00050520 00000112 mfc90u!AfxCallWndProc+0xa3
       24 0018f494 74f0c234 00050520 00000112 0000f060 mfc90u!AfxWndProc+0x37
       44 0018f4d8 776b791c 00050520 00000112 0000f060 mfc90u!AfxWndProcBase+0x56
       2c 0018f504 776b7b7a 74f0c1de 00050520 00000112 user32!_InternalCallWinProc+0x23
       90 0018f594 776bc7be 74f0c1de 00000000 00000112 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       38 0018f5cc 778ae31d 74f0c1de 00050520 00000112 user32!CallWindowProcW+0x83 (FPO: [Non-Fpo])
       28 0018f5f4 778ae4a6 0000f060 009b0337 009b0337 ole32!CFrameFilter::OnSysCommand+0x54 (FPO: [Non-Fpo]) (CONV: thiscall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 1577]
       18 0018f60c 776b791c 00050520 00000112 0000f060 ole32!FrameWndFilterProc+0x60 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 1154]
       2c 0018f638 776b925d 778ae446 00050520 00000112 user32!_InternalCallWinProc+0x23
       90 0018f6c8 776b7ccd 778ae446 00000000 00000112 user32!UserCallWinProcCheckWow+0x23c (FPO: [SEH])
       60 0018f728 776b7e23 009606b0 00000000 00000112 user32!DispatchClientMessage+0xdc (FPO: [Non-Fpo])
       38 0018f760 77b7c692 0018f778 00000000 0018f9c0 user32!__fnDWORD+0x36 (FPO: [1,6,0])
       34 0018f794 776bca50 00050520 00000112 0000f060 ntdll_77b40000!KiUserCallbackDispatcher+0x2e (FPO: [0,0,0])
       6c 0018f800 776bcb8c 009606b0 00000000 009b0337 user32!SendMessageWorker+0x2bd (FPO: [Non-Fpo])
       34 0018f834 7490f81e 00050520 00000112 0000f060 user32!SendMessageW+0x12e (FPO: [Non-Fpo])
       28 0018f85c 748817aa 01ce2db8 0018f904 7772e280 uxtheme!OnDwpNcLButtonDown+0x56459
      114 0018f970 74881ddf 00000014 009b0337 00000001 uxtheme!_ThemeDefWindowProc+0x755 (FPO: [Non-Fpo])
       14 0018f984 776ba042 00050520 000000a1 00000014 uxtheme!ThemeDefWindowProcW+0x18 (FPO: [4,0,0])
       4c 0018f9d0 776e3bbb 00050520 000000a1 00000014 user32!DefWindowProcW+0x158 (FPO: [SEH])
       38 0018fa08 776d5782 00000014 009b0337 00000000 user32!DefMDIChildProcWorker+0xe79a
       14 0018fa1c 74f18c87 00050520 000000a1 00000014 user32!DefMDIChildProcW+0x18 (FPO: [4,0,0])
       18 0018fa34 4c0e215a 000000a1 00000014 009b0337 mfc90u!CMDIChildWnd::DefWindowProcW+0x17
       2c 0018fa60 74f0e3c1 00000000 00000014 009b0337 ot1101asu!SECMDIChildWnd::DefWindowProcW+0x12a (FPO: [3,3,0]) (CONV: thiscall) [c:\program files\rogue wave\stingray studio 10.1\src\toolkit\mdi\swinmdi.cpp @ 4177]
       14 0018fa74 4c0e1ac4 0f7b7420 4c0e1a90 74f0fb36 mfc90u!CWnd::Default+0x30 (FPO: [0,0,1])
        c 0018fa80 74f0fb36 00000014 00000337 0000009b ot1101asu!SECMDIChildWnd::OnNcLButtonDown+0x34 (FPO: [3,0,0]) (CONV: thiscall) [c:\program files\rogue wave\stingray studio 10.1\src\toolkit\mdi\swinmdi.cpp @ 3785]
       b0 0018fb30 74f0f6cc 000000a1 00000014 009b0337 mfc90u!CWnd::OnWndMsg+0x443
       20 0018fb50 74f0e2f2 000000a1 00000014 009b0337 mfc90u!CWnd::WindowProc+0x24
       68 0018fbb8 74f0e57e 00000000 00050520 000000a1 mfc90u!AfxCallWndProc+0xa3
       24 0018fbdc 74f0c234 00050520 000000a1 00000014 mfc90u!AfxWndProc+0x37
       44 0018fc20 776b791c 00050520 000000a1 00000014 mfc90u!AfxWndProcBase+0x56
       2c 0018fc4c 776b7b7a 74f0c1de 00050520 000000a1 user32!_InternalCallWinProc+0x23
       90 0018fcdc 776bc7be 74f0c1de 00000000 000000a1 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       38 0018fd14 778ae02c 74f0c1de 00050520 000000a1 user32!CallWindowProcW+0x83 (FPO: [Non-Fpo])
       50 0018fd64 778ae4b0 000000a1 00000014 009b0337 ole32!CFrameFilter::OnMessage+0x88 (FPO: [Non-Fpo]) (CONV: thiscall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 2146]
       1c 0018fd80 776b791c 00050520 000000a1 00000014 ole32!FrameWndFilterProc+0x6a (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\ole32\ole232\inplace\inplace.cpp @ 1159]
       2c 0018fdac 776b7b7a 778ae446 00050520 000000a1 user32!_InternalCallWinProc+0x23
       90 0018fe3c 776b97f4 778ae446 00000000 000000a1 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       6c 0018fea8 776b9859 ffffffa1 0018fee4 74f4e491 user32!DispatchMessageWorker+0x208 (FPO: [Non-Fpo])
        c 0018feb4 74f4e491 00662f00 00000000 0045bb10 user32!DispatchMessageW+0x10 (FPO: [1,1,0])
       10 0018fec4 74f4eb18 0045bb10 0045bb10 ffffffff mfc90u!AfxInternalPumpMessage+0x40 (FPO: [0,0,2])
       20 0018fee4 74f1af81 0045c120 00000001 00000000 mfc90u!CWinThread::Run+0x5b
       14 0018fef8 004399cf 00400000 00000000 0065185e mfc90u!AfxWinMain+0x6a
       94 0018ff8c 7579919f 7ffde000 0018ffdc 77b90bbb VStudio!__tmainCRTStartup+0x150 (FPO: [Non-Fpo]) (CONV: cdecl) [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 578]
        c 0018ff98 77b90bbb 7ffde000 35f99669 00000000 kernel32!BaseThreadInitThunk+0xe (FPO: [1,0,0])
       44 0018ffdc 77b90b91 ffffffff 77b7c9d3 00000000 ntdll_77b40000!__RtlUserThreadStart+0x20 (FPO: [SEH])
       10 0018ffec 00000000 00439b3e 7ffde000 00000000 ntdll_77b40000!_RtlUserThreadStart+0x1b (FPO: [2,2,0])

And the sub-process's thread:

0:000> !wow64exts.sw
Switched to 32bit mode
0:000:x86> kv fff
  Memory  ChildEBP RetAddr  Args to Child
          0018ece0 7581dc23 00000001 000301ca 00000000 user32!NtUserWaitMessage+0xc (FPO: [0,0,0])
       40 0018ed20 75810407 00000001 00000000 00000000 user32!DialogBox2+0x13f (FPO: [Non-Fpo])
       30 0018ed50 75860ae4 000301ca 7581caef 0018ef98 user32!InternalDialogBox+0x107 (FPO: [Non-Fpo])
       c4 0018ee14 7585fa16 0018ef98 025976f8 000301ca user32!SoftModalMessageBox+0xdd7 (FPO: [1,39,4])
      16c 0018ef80 7585f75d 00000004 025976f8 00000000 user32!MessageBoxWorker+0x27f (FPO: [0,85,4])
       80 0018f000 7585f542 000301ca 025976f8 01ccec88 user32!MessageBoxTimeoutW+0x6b (FPO: [6,27,4])
       20 0018f020 7585f78e 000301ca 025976f8 01ccec88 user32!MessageBoxExW+0x1b (FPO: [5,0,0])
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for VSSupport.dll -
       1c 0018f03c 671191c2 000301ca 025976f8 01ccec88 user32!MessageBoxW+0x18 (FPO: [4,0,0])
WARNING: Stack unwind information not available. Following frames may be wrong.
       44 0018f080 74fe0a65 025976f8 00000023 00000073 VSSupport!ZWinApp::DoMessageBox+0x102
       34 0018f0b4 00403520 00000073 00000003 ffffffff mfc90u!AfxMessageBox+0x40
       1c 0018f0d0 671171b7 02582460 0018f17c 75012927 AlmCfgEd!CAlmCfgEdDoc::OnCloseRequest+0x60 (FPO: [Non-Fpo]) (CONV: thiscall)
        c 0018f0dc 75012927 74fffd23 751551aa 8bfb7d36 VSSupport!ZSptOleServerDoc::CloseRequest+0x17
       a0 0018f17c 750003f0 67120580 00000001 0018f6b0 mfc90u!_AfxDispatchCall+0x10
       a4 0018f220 765018a2 00000001 ffffff91 05952324 mfc90u!COleDispatchImpl::Invoke+0x388
       40 0018f260 764e0b2b 05952324 00000000 00000001 oleaut32!IDispatch_Invoke_Stub+0x66 (FPO: [10,2,4])
       34 0018f294 7604e0b9 0018f2d0 fde82820 764e0aa0 oleaut32!IDispatch_RemoteInvoke_Thunk+0x5b (FPO: [1,1,0])
      684 0018f918 763504d5 00214a28 00205d58 0024cad4 rpcrt4!NdrStubCall2+0x847 (FPO: [SEH])
       48 0018f960 764ed857 00214a28 0024cad4 00205d58 combase!CStdStubBuffer_Invoke+0x96 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\ndr\ndrole\stub.cxx @ 1590]
       24 0018f984 7635039d 00201ec8 0024cad4 00205d58 oleaut32!CStubWrapper::Invoke+0x47 (FPO: [Non-Fpo])
       8c 0018fa10 76253733 0022c680 74f558e0 00205d58 combase!SyncStubInvoke+0x144 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\channelb.cxx @ 1664]
      12c 0018fb3c 76351198 00205d58 0024cad4 00201ec8 combase!CCtxComChnl::ContextInvoke+0x222 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\ctxchnl.cxx @ 1377]
       a8 0018fbe4 76350bc2 00201ec8 02582470 05952320 combase!AppInvoke+0x258 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\channelb.cxx @ 1469]
      15c 0018fd40 7625277e 0024ca78 762524dd 0000babe combase!ComInvokeWithLockAndIPID+0x5fb (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\channelb.cxx @ 2311]
       34 0018fd74 757f791c 0001055c 00000400 0000babe combase!ThreadWndProc+0x2ad (FPO: [Non-Fpo]) (CONV: stdcall) [d:\blue_gdr\com\combase\dcomrem\chancont.cxx @ 683]
       2c 0018fda0 757f7b7a 762524dd 0001055c 00000400 user32!_InternalCallWinProc+0x23
       90 0018fe30 757f97f4 762524dd 00000000 00000400 user32!UserCallWinProcCheckWow+0x184 (FPO: [SEH])
       6c 0018fe9c 757f9859 00000400 0018fed8 74fde491 user32!DispatchMessageWorker+0x208 (FPO: [Non-Fpo])
        c 0018fea8 74fde491 001ec888 00000000 0042f590 user32!DispatchMessageW+0x10 (FPO: [1,1,0])
       10 0018feb8 74fdeb18 0042f590 0042f590 ffffffff mfc90u!AfxInternalPumpMessage+0x40 (FPO: [0,0,2])
       20 0018fed8 671190bc 0042f590 0018fef8 74faaf81 mfc90u!CWinThread::Run+0x5b
        c 0018fee4 74faaf81 00431e88 00000001 00000000 VSSupport!ZWinApp::Run+0x2c
       14 0018fef8 0041c62f 00400000 00000000 001d18e4 mfc90u!AfxWinMain+0x6a
       94 0018ff8c 763a919f 7ffde000 0018ffdc 77c30bbb AlmCfgEd!__tmainCRTStartup+0x150 (FPO: [Non-Fpo]) (CONV: cdecl) [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 578]
        c 0018ff98 77c30bbb 7ffde000 fc261a3b 00000000 kernel32!BaseThreadInitThunk+0xe (FPO: [1,0,0])
       44 0018ffdc 77c30b91 ffffffff 77c1c9c8 00000000 ntdll_77be0000!__RtlUserThreadStart+0x20 (FPO: [SEH])
       10 0018ffec 00000000 0041c79e 7ffde000 00000000 ntdll_77be0000!_RtlUserThreadStart+0x1b (FPO: [2,2,0])

Please help.

If this topic was not suitable being discussed here, please help advise.

Thanks,

Levi


One world, one dream

VC++6.0 Word Automation. How change color text (only) in word document?

$
0
0

   I have a program in VC++6.0 that print a word document. In this document  there is a table, I need change color text in some rows (only foreground, not background), how can do it?

Thanks for help me

How Can I Disable Temporarly Hard Disk In Running Time With Code?

$
0
0
In the name of allah
have a good time


When the system is running(windows is log on) and user does nothing, hard disk will turn off about 10 minutes.
now i need that code that turns off the hard when the system is on(Power is on) with code like the setting in power option.

actually i need the Driver Writing code.
i worked with API functions but i don't know exactly with function is needed.

can you help me please?
thanks in advance

TCP client connection problem

$
0
0

Hai all,

 Good day. my version is Visual Studio 2005. I am trying to connect server for TCP socket client program in VC++ by  i am getting error in connection. I couldn't find the problem. if i clicked the "connect" button i wnt to connect and receive data from server.

void CBarCodeDlg::OnBnClickedBconnect()
{
	// TODO: Add your control notification handler code here

	if(AfxSocketInit() == FALSE)
    {
        AfxMessageBox((LPCTSTR) L"Socket Initialiation Error");
    }
	else
	{
		AfxMessageBox((LPCTSTR) L"Socket Initialised");
	}

	CString ip_addr = (LPCTSTR) L"192.168.1.50";
	UINT port = 7000;

	m_sConnect.Create();
	m_sConnect.Connect(ip_addr, port);


	if(m_sConnect.Connect(ip_addr,port))
	{
		MessageBox((LPCTSTR) L"Client connected");

	}
	else
	{
		MessageBox((LPCTSTR) L"ERROR in connection");
	}

	char *pBuf =new char [1025];
	int iLen;
	iLen = m_sConnect.Receive(pBuf,1024);

	if(iLen == SOCKET_ERROR)
	{
		AfxMessageBox((LPCTSTR) L"Could not Receive");
	}
	else
	{
		 pBuf[iLen] = NULL;
		 m_recvData = pBuf;
		 SetDlgItemText(IDC_ECONNECTION,m_recvData);
		 UpdateData(FALSE);
		 delete pBuf;
	}
}

And my code is:


Thanks & Regards Sasi ................. Go Green


C:\gzip: Permission denied

$
0
0
in the name of allah
 
hi everyone
 
i work with Visual C++ 2008 and a part of my code, i use the gzip software that i put that in the C:\gzip directory.
but when i compile the project, the below error will be occur:
 
C:\gzip: Permission denied
1>gzip: NMAKE : fatal error U1077: 'gzip.exe' : return code '0x1'
1>Stop.

 
how can i solve that?
thanks a lot

DLL produces wrong results unless Basic Runtime Checks enabled

$
0
0

I am migrating a C++ DLL from VC 6.0 to Visual Studio 2013.  All tests have passed.

However when I compile for release incorrect results are being returned. 
I have tried numerous compiler settings and finally issolated the one compiler setting that produces a Release version that passes testing.  That setting is /RTCs.  The documentation states that this switch should never be used on retail build.

So, I have added a custom RTC error reporting function by calling _RTC_SetErrorFuncW() during startup.  Next I reran all tests and no RTC errors are reported with either Debug or Release versions of the DLL.

Adding Basic Runtime checks to my release version results in a 25% reduction in speed.

What can be done to find and fix the source of this issue?

Thanks for any suggestions,


Mac


Problem with concat

$
0
0
Hi,
Due to these 2 lines
				val.fld_str = strcat("", val.fld_nm);
				val.fld_str = strcat(val.fld_str, " ");
				...



I get these problem
Error	4	error C2440: '=' : cannot convert from 'char *' to 'char [100]'
Error	5	error C2440: '=' : cannot convert from 'char *' to 'char [100]'



how to correct them?

Many Thanks & Best Regards, Hua Min

How to solve error c1190 : MFC requires to use Winsock2.h ?

$
0
0

in the name of allah

hi everyone

i work with visual C++ 2008 and i'm a project that contains the c and c++ code together.

the project worked correctly but when i add a .cpp and a .h file to the project, the project

errors the c1189 : MFC requires to use winsock2.h

.

look the codes in the .cpp and .h files are correctly because when i add these files to another mfc project will work,

but when add to my project this error will happen.

can you tell me what the problem is?

first part of the my .h file is like below :

___

#pragma once

#ifdef _WINDOWS_
#undef _WINDOWS_
#endif

#include <Afx.h>
#include <afxwin.h>
#include <atlimage.h>
#include <math.h>

___

in addition i need to use the CWnd and CString and CImage ,... Classes in my project, because of this include the afxwin.h(for CWnd) and atlimage.h(for CImage) and ....

so i have to do these, don't i?

remaining part of .h file is :

___

class Object{
public:
    CImage Image;
    short int x,y;
};

class Theme : public CWnd{
private:
    
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

public:
    CWnd  *Parent;
    CPoint cursor;
    bool drag;
    CString path,imagepath;
    char DialogMove;//0==top to center - 1==center to top - 2==center to down - 3==down to center
    char code,sb;//code = 0=main page - sb=show button=1=ascedung,-1=desceding;
    short int iimage,bstart,bend,//i = index of images-b = index of buttons
    ib;//ib=index of button for clicking and do code
    short int w, h,D;
    float ani_p, ani_max;
    bool ani,mousec;
    CRect WRect,rdesktop;
    CDC *cdc;
    short int lani;
    HWND hwndani;
    Object *Image;
    CRect *Rect;
    bool *BEnable;//enable of buttons-1 = enable
    unsigned char ButtonCount,ImageCount,SysButtonCount;
    bool Transparent;
    int EndMsg;//0=WM_CLOSE        1=PostMessage(IDOK)

    void GotoPage(unsigned char PageNo,unsigned char BStart,unsigned char BEnd);
    void ClearRect(short i,short j,COLORREF color);
    bool IsIn(CPoint point,CRect rect);
    bool IsInRect(CPoint point,CRect rect,CRect Rectangle);
    void Center2Top(int);
    void Top2Center();
    void Down2Center();
    void Center2Down();
    bool AddImage(unsigned char Index,CString ImagePath,unsigned short int X,short int Y);
    void AddButton(unsigned char Index,CRect rectangle,bool enable);
    void DrawImages(unsigned char alpha,int IImage);
    //Theme(unsigned char imagecount,unsigned char buttoncount,unsigned char sysbuttoncount);
    void Init(unsigned char imagecount,unsigned char buttoncount,unsigned char sysbuttoncount);
    ~Theme(void);
    bool CreateTheme(CRect rect,CWnd *parent,unsigned short int W,unsigned short int H,bool transparent);
    afx_msg void OnPaint();
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    
    DECLARE_MESSAGE_MAP()
};

___

after that

in my .cpp file i wrote the body of functions.

so where the problem is?

thanks alot

___

thanks


swprintf_s issue in vs 2015

$
0
0

Hi,

This code returns a strange value! It seems that the CRT function truncates the input strings to their first character.

I get this result: "S V D"

The code compiled as Unicode. Here is the very simple code which show this problem:

.......

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
  wchar_t buf[512];
  int len = swprintf_s(buf, 512, L"%s %s %s", L"String", L"Value", L"Data");
  wcout << L"buffer: " << buf << endl;
  return 0;
}
............

This same code runs OK on the vs 2013. The issue seems to be the 'swprintf_s' function which somehow looks at the input strings as chars not wide chars.

Thanks,

G.


Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>