Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: Memory usagememberDavidCrow16 Nov '12 - 2:27 
See here.

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous


AnswerRe: Memory usagememberRolf Kristensen16 Nov '12 - 3:30 
CString csMsg;
PROCESS_MEMORY_COUNTERS_EX procMemInfo = {0};
procMemInfo.cb = sizeof(procMemInfo);
if (GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&procMemInfo, sizeof(procMemInfo)))
{
	// Log how much physical and total memory we are using
	// - Win7 (and newer) reports commit-size in this member
	if (procMemInfo.PagefileUsage==0)
		procMemInfo.PagefileUsage = procMemInfo.PrivateUsage;
	ULONG ulWorkingSetSize = (ULONG)(procMemInfo.WorkingSetSize / 1024 / 1024);
	ULONG ulPagefileUsage = (ULONG)(procMemInfo.PagefileUsage / 1024 / 1024);
	CString csProcessMemInfo;
	csProcessMemInfo.Format(_T("WorkingSetSize=%lu MBytes, CommitChargeSize=%lu MBytes"), ulWorkingSetSize, ulPagefileUsage);
	csMsg += csProcessMemInfo;
}
MEMORYSTATUSEX memStatus = {0};
memStatus.dwLength = sizeof(memStatus);
if (GlobalMemoryStatusEx(&memStatus))
{
	// Log how much address space we are using (detect memory fragmentation)
	ULONG ulUsedVirtual = (ULONG)((memStatus.ullTotalVirtual-memStatus.ullAvailVirtual) / 1024 / 1024);
	ULONG ulAvailVirtual = (ULONG)(memStatus.ullAvailVirtual / 1024 / 1024);
	CString csMemStatus;
	csMemStatus.Format(_T("UsedVirtual=%lu MBytes, AvailableVirtual=%lu MBytes"), ulUsedVirtual, ulAvailVirtual);
	csMsg += csMemStatus;
}

AnswerRe: Memory usagememberArun S J18 Nov '12 - 18:13 
Use the API GetProcessMemoryInfo()
Questioninterp project in 64bit systemmemberDang Vu Tuan15 Nov '12 - 21:46 
I have building xll addin for excel by VC in 32bit system as following: http://www.codeproject.com/Articles/5263/Sample-Excel-Function-Add-in-in-C
 
Now I'm using 64 bit system, I have try to rebuild it in 64bit system: I using 32 bit code, change Platform from 32bit to 64 bit in Configuration Manager

When I build, it is Failed:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(E:\Programming\interp_src\Debug\Interp32.dll) does not match the Linker's OutputFile property value (E:\Programming\interp_src\Interp32.xll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.xll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>.\Release/Generic.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
1>
1>Build FAILED.
 

Please help me, how can I build this xll in 64 bit system?
(I using W7-64bit, Excel 2010-64bit and VS2010)
 
Thank for helping!
AnswerRe: interp project in 64bit systemmvpRichard MacCutchan15 Nov '12 - 23:57 
It looks like you may be trying to build a mixture of 32 and 64 bit items. However, since this is connected to a CodeProject article you may get a better answer by using the forum at the end of the article to communicate with the author.
One of these days I'm going to think of a really clever signature.

QuestionSql server Database BackUpmembershibashish mohanty15 Nov '12 - 20:06 
I want to take backup of my server database into my local system.so i have used the following sql query
 
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
 

-- specify database backup directory
SET @path = 'C:\Backup\'
 

-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
 

DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name IN ('Sutra') -- exclude these databases
 

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
 

WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
 

FETCH NEXT FROM db_cursor INTO @name
END
 

CLOSE db_cursor
DEALLOCATE db_cursor
 
i have created the Backup folder in C: drive.but it returns the following error
 
Msg 3201, Level 16, State 1, Line 28
Cannot open backup device 'C:\Backup\Sutra_20121116.BAK'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 28
BACKUP DATABASE is terminating abnormally.
 
Please solve it.Thanks in advance
shibashish mohanty

AnswerRe: Sql server Database BackUpmvpRichard MacCutchan15 Nov '12 - 23:55 
Does this have something to do with C++?
One of these days I'm going to think of a really clever signature.

AnswerRe: Sql server Database BackUpmemberAndré Kraak16 Nov '12 - 0:48 
As mentioned in this article: http://blog.sqlauthority.com/2011/12/17/sql-server-fix-error-msg-3201-level-16-cannot-open-backup-device-operating-system-error-3-the-system-cannot-find-the-path-specified/[^] did you create the backup folder on the machine where the SQL instance is running on or on the machine where you are running the script?
It should be created on the machine where the instance is running on.
0100000101101110011001000111001011101001

QuestionNeed help compilingmemberxLeonx15 Nov '12 - 8:51 
Hello i believe i have the source code for my program i developed but i am having trouble compiling it. Any help would greatly be appreciated thanks Leon WTF | :WTF:
AnswerRe: Need help compilingmemberjeron115 Nov '12 - 9:51 
See here first.[^]
QuestionRe: Need help compilingmemberDavidCrow15 Nov '12 - 10:34 
xLeonx wrote:
Hello i believe i have the source code for my program i developed...
You're not sure? Confused | :confused:
 
xLeonx wrote:
...but i am having trouble compiling it.
And that trouble would be what exactly?
 
xLeonx wrote:
Any help...

Such as?

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous


QuestionRe: Need help compilingmvpCPallini15 Nov '12 - 23:09 
What IDE or compiler are you using?
At least, what Operating System are you using?
Veni, vidi, vici.

AnswerRe: Need help compilingmemberxLeonx18 Nov '12 - 9:35 
Thanks for the reply. Sorry about being vague. Well i have windows 7. I have what i think is the source code for a program i had developed by a programmer. Well to make a long story short i had a fire a my plant and all my software burned up. All i have is what i think is the source code but i don't know how to compile it. The program is about a meg in size so i could easily email it. Well thanks again your help is greatly appreciated.
AnswerRe: Need help compilingmemberStephen Hewitt16 Nov '12 - 22:36 
A tad lean on details.
Steve

GeneralRe: Need help compilingmemberxLeonx18 Nov '12 - 9:31 
Thanks for the reply. Sorry about being vague. Well i have windows 7. I have what i think is the source code for a program i had developed by a programmer. Well to make a long story short i had a fire a my plant and all my software burned up. All i have is what i think is the source code but i don't know how to compile it. The program is about a meg in size so i could easily email it. Well thanks again your help is greatly appreciated.
GeneralRe: Need help compilingmemberxLeonx18 Nov '12 - 9:33 
Thanks for the reply. Sorry about being vague. Well i have windows 7. I have what i think is the source code for a program i had developed by a programmer. Well to make a long story short i had a fire a my plant and all my software burned up. All i have is what i think is the source code but i don't know how to compile it. The program is about a meg in size so i could easily email it. Well thanks again your help is greatly appreciated.
AnswerRe: Need help compilingmemberArun S J18 Nov '12 - 18:15 
Please describe your actual problem
GeneralRe: Need help compilingmemberxLeonx23 Nov '12 - 8:20 
Thanks for the reply. Sorry about being vague. Well i have windows 7. I have what i think is the source code for a program i had developed by a programmer. Well to make a long story short i had a fire a my plant and all my software burned up. All i have is what i think is the source code but i don't know how to compile it. The program is about a meg in size so i could easily email it. Well thanks again your help is greatly appreciated.
GeneralRe: Need help compilingmemberArun S J25 Nov '12 - 17:37 
It is ok . colud you please clarify that the code is in which language? What developemnt media is used for developing the code?
QuestionVisual Studio 2003 on Windows 8!memberHadi Dayvary15 Nov '12 - 4:23 
Hi
Has anybody tested Visual Studio 2003 on Windows 8?
Is it like Windows7?
 
Regrads
www.logicsims.ir

Question[RESOLVED] Message Box will not show on top of windowmemberBrandon T. H.15 Nov '12 - 1:14 
Hello people this is me again,
 
I'm making a chat application program, that people can communicate over a computer network or V.P.N. (virtual private network) and when a user clicks the red close button a message box is suppose to show, but does not, here's the code:
 
#include <windows.h>
#include "stdafx.h"
 
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
 
/*  Make the class name into a global variable  */
char szClassName[ ] = "netchat_ad";
 
int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
 
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
 
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME));
    wincl.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_NETTYPE), IMAGE_ICON, 16, 16, 0);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
 
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;
 
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "netCommunication - [NET: <none>]",       /* Title Text */
           WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           500,                 /* The programs width */
           400,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
 
           if (!hwnd) {
           MessageBox(0, "Failed to create the window, ending program.", "Handle Error", MB_OK | MB_ICONERROR);
           return 2;
           }
 
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);
 
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }
 
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}
 

/*  This function is called by the Windows function DispatchMessage()  */
 
    HFONT font1 = CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
        CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Microsoft Sans Serif"));
 
    HFONT font2 = CreateFont(14,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
        CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Microsoft Sans Serif"));
 
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
 
        HWND messagebox, sendmesbutton;
 
        messagebox = CreateWindow(TEXT("edit"), TEXT(""),
                WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | WS_VSCROLL,
                71, 317, 320, 32,
                hwnd, (HMENU) 1, NULL, NULL
            );
 
         sendmesbutton = CreateWindow(TEXT("button"), TEXT("Send\n(Message)"),
                WS_VISIBLE | WS_CHILD | WS_BORDER | BS_MULTILINE,
                397, 317, 75, 33,
                hwnd, (HMENU) 2, NULL, NULL
            );
 
            SendMessage(messagebox,WM_SETFONT,(WPARAM)font2,MAKELPARAM(true,0));
            SendMessage(sendmesbutton,WM_SETFONT,(WPARAM)font1,MAKELPARAM(true,0));
            break;
 
        case WM_PAINT:
 
            break;
 
        case WM_SETFONT:
 
            break;
 
        case WM_CLOSE:
 
            int mbcce;
            mbcce = MessageBox(hwnd, "Are you sure you want to exit the chat and close the session?", "Close Connection", MB_YESNO | MB_ICONINFORMATION);
 
            if (mbcce == IDYES) {
                DestroyWindow(hwnd);
            } else if (mbcce == IDNO) {
            }
 
            break;
 
        case WM_COMMAND:
 
            if (LOWORD(wParam) == 2) { /* When the message box button is clicked, try to send the message. */
 
            }
 
            break;
 
        case WM_DESTROY:
			PostQuitMessage(0);
			break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
 
    return 0;
}
 

 
Technically the message box appears because I can hear the dialog pop up and can use the enter or arrow keys to select a command, but the problem I am having is that I cannot see it. I was wondering if you'll can spot my error.
Simple Thanks and Regards,
Brandon T. H.
 
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
 
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

AnswerRe: Message Box will not show on top of windowmvpRichard MacCutchan15 Nov '12 - 3:16 
1. You should follow the call to ShowWindow() with a call to UpdateWindow(), to get your controls drawn straight away.
 
2. Your WindowProcedure() has a case for handling the WM_PAINT message, so Windows thinks you are handling it even though you are not. If you remove that case* then your MessageBox will show up on its own. As a general rule you should not add case statements for messages that you ignore. As a simple test before changing your code, press the close button on your window and then press the Alt key on your keyboard.
 
*I have come across this before but have not tried to figure out exactly why it happens. There is probably someone who works or worked for Microsoft who knows the answer.
One of these days I'm going to think of a really clever signature.

GeneralRe: Message Box will not show on top of windowmemberBrandon T. H.15 Nov '12 - 8:13 
It works now, thank you (I removed the WM_PAINT system call code).
 

Richard MacCutchan wrote:
As a simple test before changing your code, press the close button on your window and then press the Alt key on your keyboard.

The message box appears (with the WM_PAINT).
 

Richard MacCutchan wrote:
*I have come across this before but have not tried to figure out exactly why it happens. There is probably someone who works or worked for Microsoft who knows the answer.

That is weird, I should ask one, one of these days or maybe e-mail one.
 

Richard MacCutchan wrote:
There is probably someone who works or worked for Microsoft who knows the answer.

That could be anyone, you mean computer programmer or software developer.
Simple Thanks and Regards,
Brandon T. H.
 
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
 
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

GeneralRe: Message Box will not show on top of windowmvpRichard MacCutchan15 Nov '12 - 23:42 
Brandon T. H. wrote:
The message box appears (with the WM_PAINT).
I suspect that the issue is connected to the fact that your code was consuming the WM_PAINT message, so the system did not try to do anything connected with displaying your windows (including the message box).
 
Brandon T. H. wrote:
you mean computer programmer or software developer.
Same thing.
One of these days I'm going to think of a really clever signature.

GeneralRe: Message Box will not show on top of windowmemberBrandon T. H.17 Nov '12 - 4:30 
Richard MacCutchan wrote:
I suspect that the issue is connected to the fact that your code was consuming the WM_PAINT message, so the system did not try to do anything connected with displaying your windows (including the message box).

I did, strangely, as soon as the main window popped up for my project, the window was blank (no controls, nothing on it), but when I go to re-size it and/or move it around, the controls appeared. But the message box did not, until you told me to press the ALT key.
Simple Thanks and Regards,
Brandon T. H.
 
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
 
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 22 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid