Removing the Serialized values of an activex control
Hi,
How can i remove the values serialized by an activex control? I am
running into trouble when i introduced new properties for an existing
activex control.
Regards,
John. Tag: memory allocation Tag: 279563
any clues please
hey all,
i'm trying to compile a sample program i read from an article and i'm
getting 2 errors that i have no clue because it doesn't point to any source
code? please look at the following video (ie6 or earlier).
http://www25.brinkster.com/rodchar/medtest.htm
thanks,
rodchar Tag: memory allocation Tag: 279552
Why doesn't an underflow ( e.g. X *= 0 ) bring down the house ?
Back around 1995, VC's default settings had
a floating-point divide-by-zero would terminate the app.
Even today, an integer divide-by-zero terminates the app.
Why stop the whole show just because an int overflowed ?
How can I turn this " feature " off ?
Why doesn't an underflow ( e.g. X *= 0 ) bring down the house ?
F.Y.I.: For for the 8 bit exponent in VC's â?? float â??,
infinity is 255 ( 2^128, â?? _isnan() == 1 â?? )
and zero is zero ( notionally 2^-127, provided: â?? _clearfp() == 0 â?? ).
The largest " true " float is 2^128 - 1 ( FLT_MAX )
and the smallest is 2^-126 ( FLT_MIN ). Tag: memory allocation Tag: 279549
How to disable Windows FIle Protection System.
Hello,
I need to implement a class that disbales Windows File Protection
(WFP) untill next reboot and that shouldn't require Rebooting the
system.
Please help me out if anyone has idea about it,
Regards
Amit Tag: memory allocation Tag: 279548
problem with DECLARE_PROPPAGEIDS
Hi,
In my activex control i tried to add new property page everything
compiled fine. But the problem is while registering the control it is
showing an assertion failure. while debugging i found that the problem
is with DECLARE_PROPPAGEIDS. While i comment this thing in the
controls header file, no assertion failure is throwing up. Any idea
what is causing the problem?
DECLARE_PROPPAGEIDS(CMyCtrl)
BEGIN_PROPPAGEIDS(CMyCtrl, 1)
PROPPAGEID(CMyCtrlPropPage::guid)
END_PROPPAGEIDS(CMyCtrl)
I tried changing the guids when i encountered this error. But it is of
no effect. Tag: memory allocation Tag: 279547
Get Visual Studio to compile a different C file from the one in the project..?
I am having a hard time trying to do this rather arcane thing. Let me
explain
I have a firmware codebase which is full of non-standard C extensions.
This codebase is then munged by a tool which I invoke using a custom
build step or pre-build event to write a new C file which MSVC can
compile.
I can of course simply run a batch file to copy the original somewhere
else, and rename the munged file, but I want to be able to step
through the original source in the debugger. This is possible using
the #line directive in the munged version. However, the stumbling
block seems to be getting the compiler to compile the munged file and
not the original.
So my question is: Is it possible to get MSVC to compile a
different .c file while still keeping the original in the project?
Any ideas?
Andrew Tag: memory allocation Tag: 279546
Static variable initialization.
Hi,
In a program of mine I have several singleton classes (see below for the
basic interface).
I noticed that the constructors for the classes are called in an
arbitrary order. As a result a call to a singleton's Get function can
return a reference to an object whose constructor has not been called
yet! This only happens when I call a singleton's Get function from
another singleton's constructor. Is this behavior normal, or is this
just something that Windows CE does for me?
I've made a workaround, but would like to know if this behavior is
according to the C++ standard, or a bug.
Regards,
Sytse.
class A
{
private:
A()
{
}
static A g_A;//Global instance
public:
static A& Get()
{
return g_A;
}
...
} Tag: memory allocation Tag: 279538
MDIGetActive not Working!! Help Required
Hi,
I have created a Modeless Dialog Box using threads (CWinThread). The
thread invokes a dialog box (derived from CDialog) which acts as
modeless. The thread is invoked through a menu handler in CMyView
class. Now in my dialog box that is invoked in Cwinthread derived
class , i want my doc or view data to be there. Now can u tell me how
can i do that.
I tried this but the execution terminates abnormally. I placed a
static function in CMyDoc to return a pointer to the active document.
In this function i used AfxGetApp() to get m_pMainWnd and then
MDIGetActive() to get active frame. I have called this function in my
dialog's OnInitDialog() function. It is the MDIGetActive() that is
causing abnormal execution. Can u help? Code for static function is:
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
if ( !pChild )
return NULL;
CDocument * pDoc = pChild->GetActiveDocument();
if ( !pDoc )
return NULL;
// Fail if doc is of wrong kind
if ( ! pDoc->IsKindOf( RUNTIME_CLASS(CMyDoc) ) )
return NULL;
return (CMyDoc *) pDoc;
Thanx in advance Tag: memory allocation Tag: 279532
How to read uncode encoded files?
Hi.
I try to read unicode encoded files.
File starts with unicode BOM (0xFEFF).
Here's the file content.
FF FE 42 00 45 00 47 00 49 00 4E 00
And I use following code.
if ((fd = _open(buffer, _O_RDONLY)) != -1)
{
while (_read(fd,&mem, 1) == 1)
;
_close(fd);
}
When I check the contents of 'mem'.
The contents of 'mem' are
42 45 47 49 4E
Why this happen?
How can I read Unicode BOM (0xFEFF)? Tag: memory allocation Tag: 279525
no response from serial port
I have a laser shutter that operates through a serial port, say COM1.
The only input the shutter needs is a "\n@" command that sets the
shutter to open/closed position. I have no problem controlling the
shutter through a hyperterminal.
But when I try to control the instrument through an MFC .NET 2003 app
I get very slow response, and I can't get the shutter to open/close. I
copied all the COM1 settings I have set in the hyperterminal:
CSerial serial;
LONG lLastError = ERROR_SUCCESS;
lLastError = serial.Open("COM1");
OutputDebugString("Opened serial port for shutter control!\n");
lLastError =
serial.Setup(CSerial::EBaud300,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
OutputDebugString("Settings for serial port for shutter control OK!
\n");
lLastError = serial.SetupHandshaking(CSerial::EHandshakeHardware);
OutputDebugString("Hanshaking for serial port for shutter control OK!
\n");
lLastError = serial.Write("\n\@");
OutputDebugString("Sent data for shutter control!\n");
serial.Close();
The delay between the "handshaking OK" message and the "sent data"
message can be as long as ~10 seconds, and the shutter does not open/
close anyway. So the communucation seems to be there, but smth is
wrong. How can I debug this? The original working hyperterminal
connection is set at 300 baud rate, 8 data bits, no parity, 1 stop
bit, and no flow control. It also needs ASCII echoed, but that
probably is irrelevant.
The above routine works just fine for COM3 which controls another
instrument, with different settings. Tag: memory allocation Tag: 279524
how do i look it up?
hey all,
i've been reading petzold and he says to look it up in the header files to
find more detail. for instance, where can i go to see what's in <windows.h>?
thanks,
rodchar Tag: memory allocation Tag: 279518
correct usage of ostringstream
The two functions foo() and bar() are trying to do the same thing. foo
doesn't work but bar does. My question "Is bar a leagal function or is
it treading into the undefined behaviour and I'm simply getting away
with it"? I have tried the code both in VC 6 and VC 2005. Both exhibit
the same behaviour.
As long as I use the ostringstream::str() function as the first output
variable it seems to work. As soon as it appears in a different
location, the code will crash.
#include "stdafx.h"
#include <string>
#include <sstream>
using namespace std;
std::string SomeFunc( const std::string &str )
{
// Iterate through string and calculate a checksum
return " checksum ";
}
void foo()
{
const char stx = '\2';
const char etx = '\3';
std::ostringstream os;
os << stx
<< "One"
<< SomeFunc(os.str().substr(1)) // crashes here
<< etx;
std::string done = os.str();
}
void bar()
{
const char stx = '\2';
const char etx = '\3';
std::ostringstream os;
os << stx
<< "One";
os << SomeFunc(os.str().substr(1)) // works but why?
<< etx;
std::string done = os.str();
}
int main(int argc, char * argv[])
{
argc; argv;
foo(); // doesn't work
bar(); // works fine
return 0;
} Tag: memory allocation Tag: 279513
Help with a patch
I want to inject the following code into the host of my DLL and patch it to
remove references to memory locations in my DLL.
#pragma code_seg(".inject")
LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
if ( uMsg == WM_SYSCOMMAND && (wParam & 0xFFF0) == SC_CLOSE )
wParam = SC_MINIMIZE;
return CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam);
}
#pragma code_seg()
#pragma comment(linker, "/SECTION:.inject,R")
#define INJECT_SIZE 0x3E // from DUMPBIN.EXE
As far as I can tell the only reference to memory locations in my DLL is the
reference to "OldWndProc" (gotten when the new WNDPROC is set). But when I look
at the machine code I see two references to memory locations in my DLL:
55 8B EC 81 7D 0C 12 01 00 00 75 16 8B 45 10 25
F0 FF 00 00 3D 60 F0 00 00 75 07 C7 45 10 20 F0
00 00 FF 75 14 FF 75 10 FF 75 0C FF 75 08 FF 35
[ 60 F0 7E 01 ] FF 15 [ 2C C1 7E 01 ] 5D C2 10 00
The first is the expected location of "OldWndProc". What's the second? If it's
a jump to CallWindowProc, how would I patch it? [The exe is build with Borland.]
Thanks.
--
- Vince Tag: memory allocation Tag: 279510
dll interface specification and includes
Hi.
I have a dll I've written in visual studio 2005 standard.
It has a bunch of functions that are defined similarily to this
in a header:
__declspec(dllexport) int LoadStuff(int & parm1, char * parm2);
__declspec(dllexport) int UnLoadStuff(void);
Now, I load this library dynamically from another app developed in
another vendors older compiler.
There I have code like this in a header:
typedef int (* cdecl functionPointerLoadStuff)(int & parm1, char *parm2);
typedef int (* cdecl functionPointerUnLoadStuff)(void);
and in the same file I have this:
class myClass
{
public:
functionPointerLoadStuff functionLoadStuff;
functionPointerUnLoadStuff functionUnLoadStuff;
};
Finally in my class implementation I have code like this:
functionLoadStuff = (functionPointerLoadStuff )
GetProcAddress(hLibrary,"LoadStuff");
functionUnLoadStuff = (functionPointerUnLoadStuff)
GetProcAddress(hLibrary,"UnLoadStuff");
I'm wondering if there is some way to not have to maintain the header files
separately since in a sense they both code for the same interface. I'd rather
not have to separately update each one if at all reasonably possible.
I'm not so sure that the other vendors old compiler will recognize everything,
but I'm perusing the possibilities now.
Thanks
Jeff Kish Tag: memory allocation Tag: 279506
Creating Popups and Display Graph
Hi,
I have an MDI App. I have a doc and view opened displaying some data.
Now in my menu I have a View->Plot item (ID_VIEW_PLOT) clicking on
which a new window (popup) will open on which I can display a graph.
To display a graph i need a CFormView derived view window which gets
displayed on clicking View->Plot. Can anyone detail me out how i can
do
this.I have the code to display charts but i need the way to create a
popup which uses my CFormView derived class to display the pop up
dialog. I need to have the handler for ID_VIEW_PLOT in CFormView
derived class and not in CWinApp nor in CMyAppView class. I want 2
type of view classes wherein the form view opens only if i click the
menu item.
Thanx in advance. Tag: memory allocation Tag: 279505
Unhandled Exception from mscorlib.dll
Hi, I have an application that is mostly Java, but uses a dll that I
built with Visual C++ (Visual Studio 2005). The dll is responsible for
setting folder permissions (Java can't do this without going native).
I've gotten the code work under normal circumstances, but I've noticed
that if I try to set permissions for a user that doesn't exist
(someone could enter an invalid user name), I get an exception of
System.Security.Principal.IdentityNotMappedException. This really
isn't too much of a problem, and I've managed to catch it in a try
block.
My problem is that even though I catch this exception, it is somehow
bubbled up to the running JVM, as it crashes with an error pop up
window showing:
The instruction at "0x7c910e03" referenced memory at "0x66657220". The
memory could not be "written".
Click OK to terminate the program
The memory locations seem to always be the same. I've done some
testing and have tested manually throwing an exception of this type in
a different dll and when I catch it, I get no problems reported to the
jvm. If I don't catch it, it's a completely different crash altogether
and the JVM reports this as a bug in the JVM, so it's not that an
exception is making its way up uncaught.
The C++ code is mixed (managed/unmanaged) and the permissions are set
on the folder through some .NET 2.0 calls. This is what is throwing
the initial exception. I have suspect that my problem has to do with
this. Also, when running this code without catching the exception, the
debugger says that the exception occurred in mscorlib.dll. I'm
thinking that this could also be partly why Java is seeing the error
since the exception is being generated outside of my own dll.
I understand that this may be somewhat off topic as I'm interfacing
with Java, or may be more related to the .NET framework, but it seems
like I'm missing something from Visual C++.
Any help is greatly appreciated.
Thanks,
Will
Here is the shortest sample of C++ code that does what I need:
using namespace System;
using namespace System::Security::AccessControl;
using namespace System::IO;
int main(array<System::String ^> ^args)
{
String ^folder = "C:/Documents and Settings/will/Desktop/testFolder";
String ^user = "wrongDomain\\wrongUser";
FileSystemAccessRule ^container = gcnew FileSystemAccessRule(user,
FileSystemRights::Modify, InheritanceFlags::ContainerInherit,
PropagationFlags::None, AccessControlType::Allow);
FileSystemAccessRule ^object = gcnew FileSystemAccessRule(user,
FileSystemRights::Modify, InheritanceFlags::ObjectInherit,
PropagationFlags::None, AccessControlType::Allow);
DirectorySecurity ^dirSecurity = Directory::GetAccessControl(folder,
AccessControlSections::Access);
dirSecurity->SetAccessRuleProtection(true, false);
//try {
dirSecurity->AddAccessRule(container); // Exception gets thrown here
for a bad user
dirSecurity->AddAccessRule(object);
Directory::SetAccessControl(folder, dirSecurity);
//} catch(System::Security::Principal::IdentityNotMappedException
^ex) {
// Console::WriteLine("Caught Exception " + ex->Message);
//}
Console::ReadKey();
return 0;
} Tag: memory allocation Tag: 279487
corrupt windowProc()
hi,
i have a question:
i've worked with a corrupt windowProc() for a long time.
instead of calling DefWndProc(), i issued a
'return 0;'.
the problem is that, it messed with XP, and
when i (for instance ) move the mouse with
'control' pressed or 'shift',
the mouse jerks.
reinstalling the mouse and keyb. drivers doesn't
help.
how do i fix this?
(i already fixed wndProc().)
greets,
marc Tag: memory allocation Tag: 279478
const WCHAR *
const WCHAR* nodeval;
if (FAILED(hr = pReader->GetValue((LPCWSTR *)&nodeval, NULL)))
{
wprintf(L"Error getting value, error is %08.8lx", hr);
return -1;
}
When I try debugging the const WCHAR* datavariable in the locals
screen, I keep getting a <Bad Ptr> displayed as the Value. How
exactly does the const WCHAR * work and how do I know if that pReader-
>GetValue function is actually setting nodeval correctly?
Thanks Tag: memory allocation Tag: 279477
Subclass host EXE's HWND then unload DLL?
In a DLL (plugin extension for an EXE) I write the following WNDPROC to the
EXE's address space. Its purpose is simply to turn <WM_SYSCOMMAND, SC_CLOSE>
into <WM_SYSCOMMAND, SC_MINIMIZE> (make the app hard to exit).
#pragma code_seg(".inject")
LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
static WNDPROC LocalOldWndProc = NULL;
static BOOL bNeedInit = TRUE;
// CWP = CallWindowProc()
static LRESULT (WINAPI *CWP)(WNDPROC, HWND, UINT, WPARAM, LPARAM);
if ( bNeedInit )
{
LocalOldWndProc = OldWndProc;
HMODULE hUser32 = GetModuleHandle("user32.dll");
(FARPROC&) CWP = GetProcAddress(hUser32, "CallWindowProcA");
bNeedInit = FALSE;
}
if ( uMsg == WM_SYSCOMMAND && (wParam & 0xFFF0) == SC_CLOSE )
wParam = SC_MINIMIZE;
return CWP(LocalOldWndProc, hwnd, uMsg, wParam, lParam);
}
#pragma code_seg()
#pragma comment(linker, "/SECTION:.inject,R")
#define INJECT_SIZE 0x74 // from DUMPBIN.EXE
I inject the code as follows:
BYTE *NewWndProc = (BYTE*) VirtualAlloc(NULL, INJECT_SIZE, MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
BYTE *p = (BYTE*) MyWindowProc, *q = NewWndProc;
for ( INT i=0; i<INJECT_SIZE; i++ ) *q++ = *p++; // inject new wndproc
OldWndProc = (WNDPROC) SetWindowLong(hWndAppFrame, GWL_WNDPROC, (LONG)
NewWndProc);
SendMessage(hWndAppFrame, WM_NULL, 0, 0); // make it initialize
The point of the new WNDPROC's initialization routine is to remove any future
reference to memory locations in the DLL.
It all works fine but the DLL can't be unloaded (I'd like to unload it, leaving
the subclassing in place). If the DLL unloads (just before app shutdown or at
my request) there are two GPF's in module_unknown and one in kernel32.dll
(apparently in DuplicateHandle() (?).
Am I missing something fundamental here, something that would make the crash
expected?
Thanks.
--
- Vince Tag: memory allocation Tag: 279476
win32 api walkthrough request
hey all,
could someone please do a simple walkthrough with me on how create a simple
window app that has a tab control on it with maybe a single button in one of
the tabs that does a simple hello world message.
i'm still trying to grasp some concepts here so please be gentle. if
possible, could it be as close to low-level c++ as possible (which means to
me and i could be a wrong newbie: no mfc or extra existing libraries). i
don't even know how possible that is.
thanks,
rodchar Tag: memory allocation Tag: 279469
Displaying Graphs
I have used ur way and its working fine. But i still have a little
problem. I will explain to you my situation and please let me knoe if
you can help.
I have an MDI App. I have a doc and view opened displaying some data.
Now in my menu I have a View->Plot item (ID_VIEW_PLOT) clicking on
which a new window (popup) will open on which I can display a graph.
To display a graph i need a CFormView derived view window which gets
displayed on clicking View->Plot. Can u detail me out how i can do
this. I need to have the handler for ID_VIEW_PLOT in CFormView derived
class and not in CWinApp class. With your previous solution I am able
to create new windows. But now i want 2 type of view classes wherein
the form view opens only if i click the menu item.
Thanx in advance.
Rishabh Tag: memory allocation Tag: 279463
VS2005 SP1 Hell
We upgraded to VS2005 SP1 and of course our code doesn't run now :-) We get
the "app config is incorrect, etc.".
Anyway, I think its because its not loading the right runtime libraries.
So, we've updated our installation so that the SP1 runtime libraries get put
in our app directory now. Problem is, its still loading the libraries from
the SxS storage area.
We really don't want to force every user to go run some other MS runtime
install kit to be able to run our SW.
So... the question is, how do we force our app to load the runtime libs from
the app directory?
This used to be a simple matter of putting all the right DLLs in your app
directory.
Whats the easiest way to do this? Tag: memory allocation Tag: 279461
MD5 Hashing
Hi there,
Is it possible to create an MD5 hash of a series of bytes using the
Crypto API?
I'm presuming that the .NET Framework MD5CryptoServiceProvider merely
wraps the win32 API.
If so, does anyone have any examples of doing this? Many thanks in
advance.
Nick. Tag: memory allocation Tag: 279451
Creating MDI Child Windows
In my application(MDI AppWizard exe) I want to create a new child
window
when i click a certain menu item in my main menu (like in File->New)
where I can display a graph. Please tell me how I can a create a new
child window and use it.
Thanx in advance,
Rishabh Tag: memory allocation Tag: 279450
Exception and GetLastError()
Hi there:
look at code blow
////////////////////
try
{
blah blah blah
}catch(...)
{
DWORD dw = GetLastError()
}
////////////////////
Does it make sence to call GetLastError() in catch block?
In my opinion, I dont think it's necesary do like above, but could sure
about it. Tag: memory allocation Tag: 279414
context switch
I was just wondering if Windows XP always saves and restores the MMX
and SSE registers during a context switch. Any help is appreciated.
Thank you. Tag: memory allocation Tag: 279413
multi-process singleton DLL
I have a DLL that exports a class that allows a program to access a
unique system resource.
At the moment, the DLL is implemented as a singleton such that any
thread in a given process is using the same resource handle.
But, if a second, unrelated process loads the DLL and accesses it,
this process will try to create its own handle to the resource which
fails because it's already in use by the first process.
How do I give the second process access to the handle that's being
used by the first process so that both can query the resource?
Thanks,
PaulH Tag: memory allocation Tag: 279412
Hadnling Large memory
Imagine 2 GB of memeory map data and if user changes a bit we should be able
to find the resultant change in the binary location update that specific byte.
Give me some larger memory based comparison APIs in .NET. Tag: memory allocation Tag: 279408
Questions about VC++
Hi dear experts,
I'm not experienced in VC++ but i have VC++ 6.0 just for a very few
experience. I'm confused and i need to know someting about C++
application development under VC++ 6 or more.
Here to go:
1-Is the most efficent way to develop GUI-based applications possible
with MFC or what else? What's MFC used for?
2-What's the best way to learn VC++ or C++ with Windows app.
developing? Which books? Web tutorials? There are some and a few free
tutorials which are very fragmented and need to know which dicipline
or procedure(s) is/are the most strong steps to learn VC++ ? I
appreciate if you had useful steps till right now with your
experiences.
3-When compared to Basic, VC++ or C++ seems much more complicated and
has more mistake rist while coding, that's why i'm a bit concerned, so
what are the basics understanding of Visual C++ enviroment/C++ ? (For
example: Declarations, strings, using variables...)
These can be generated more, so please post your feedback in order to
undertand about VC++ coding disipline, recognizing enviroment and
programming basics/tricks to make explicit things.
Regards... Tag: memory allocation Tag: 279393
GETMESSAGE hook, WM_SYSCOMMAND, SC_CLOSE, and the "X" button?
In an extension (DLL) to a subsystem:windows app I'm trying to make the app hard
to close. A simple WH_GETMESSAGE hook correctly sees <WM_SYSCOMMAND, SC_CLOSE>
when it's generated by the system menu's "Close" (also <Alt-F4>) and translates
it into <WM_SYSCOMMAND, SC_MINIMIZE>. But my hook fails to see <WM_SYSCOMMAND,
SC_CLOSE> when it was generated by the title bar's "X" button. The application
does not set any other hooks.
What's going on here? Can I work around it?
Thanks.
--
- Vince Tag: memory allocation Tag: 279391
Performance issue
Hi,
I'm trying to improve the performance, but found some issue.
When a function call from FileA to FileB that will have performance loss.
But if the both function in the same file that will have a better peformance.
Is it normal? Or have some way to improve it?
FileA.cpp
------------
HRESULT functionA()
{
return S_OK;
}
void functionMain()
{
for (int i=0; i<10000; i++)
functionA();
for (int i=0; i<10000; i++)
functionB();
}
FileB.cpp
------------
HRESULT functionB()
{
return S_OK;
}
--
Herman Man
Tetragames Studio Limited Tag: memory allocation Tag: 279384
Instantiate Class with/without operator new?
Hi,
I'm trying to understand the difference between instantiating a generic
C++ class, A) using operator new, B) not using operator new. I have a
simple class called Numbers, that can add or multiply two ints supplied
to the constructor. It seems to work regardless of whether I use new or
not. I'm interested to know when I should use new for Class
instantiation and when not to use it. I tried to find the answer by
searching, but 'new' is not a very common word.
Here's how my calling code looks in _tmain(), note one instance uses
pointers, the other does not
int a,b;
Numbers * n1 = new Numbers(4,5);
a = n1->Add();
wcout << a << endl; // prints 9
b = n1->Multiply();
wcout << b << endl; // prints 20
delete n1;
Numbers n2 = Numbers(5,6);
a = n2.Add();
wcout << a << endl; // prints 11
b = n2.Multiply();
wcout << b << endl; // prints 30
--
Gerry Hickman (London UK) Tag: memory allocation Tag: 279369
File IO related issue
Hi there:
Is there any APIs to detect the files are being operating by some API ,
such as WriteFile? Tag: memory allocation Tag: 279365
Define a larger code block
Hi,
As I can define something like
#define ABC(x) if(x){x = NULL;}
but how can I define something similar but the code block is relatively
large (like several lines testing different cases, etc)?
Thanks,
Alan Tag: memory allocation Tag: 279349
System Requirements for Express Edition
I would like to install the Express Edition on a system that does not
have the memory/process speed shown under the system requirements for
this edition.
If my system is undersized, will the Express Edition not function at
all? Or just slowly. Anyone have experience here?
Thanks in advance Tag: memory allocation Tag: 279333
Template function question
I'm using Visual Studio .NET 2003. I don't understand what's going on
with this code (why the compiler accepts the call to DoSomething2 but
not DoSomething1) :
template< typename T >
void DoSomething1( void (*)( T ), T );
template< typename T >
struct wrap_type
{
typedef T type;
};
template< typename T >
void DoSomething2( void (*)( T ), typename wrap_type< T >::type );
void F1( const int & );
void main()
{
// error C2782: 'void DoSomething1(void (__cdecl *)(T),T)' :
template parameter 'T' is ambiguous
// could be 'int'
// or 'const int &'
//DoSomething1( &F1, 1 );
// Works
DoSomething2( &F1, 1 );
}
Any insights would be appreciated.
---Chris Tag: memory allocation Tag: 279328
resource editor newbie
hey all,
what is the story behind the resource editor? Does every project need one?
Is this like the form designer in c#.net?
thanks,
rodchar Tag: memory allocation Tag: 279326
application configuration
hey all,
i'm trying to create a file that holds settings for when my application
starts up. can someone please tell me what are the new and old ways of doing
this?
thanks,
rodchar Tag: memory allocation Tag: 279321
One-time initialization of statics in a multithreaded world
Hi everybody,
I cooked a macro for initializing objects once in our project, could
you review and criticize it, please?
I'm mostly interested in correctness, not performance :)
I must say that I don't care about reentrance in the same thread (the
potential "problem" I see) and that I don't want to go through the
InitOnce* API.
#define ONE_TIME_INITIALIZE(TYPE, NAME, INITIALIZER) \
static TYPE* NAME##StaticPtr = NULL;\
static LONG NAME##InitState = 0;\
if(InterlockedCompareExchange(&NAME##InitState, 1, 0) == 0) \
{ \
static TYPE NAME##Handle(INITIALIZER); \
InterlockedExchangePointer(&NAME##StaticPtr, &NAME##Handle); \
InterlockedExchange(&NAME##InitState, 2); \
} \
else \
{ \
while(InterlockedCompareExchange(&NAME##InitState, 2, 2) != 2)
{} \
} \
TYPE* NAME##Ptr;\
InterlockedExchangePointer(&NAME##Ptr, NAME##StaticPtr); \
TYPE& NAME = *(NAME##Ptr);
Thanks in advance,
Bertrand Tag: memory allocation Tag: 279320
Portability and MDI Application
Hi,
I am creating an application using MS Visual C++ 6.0 and MFC
(AppWizard exe). But when I run its debug version in other computers
where Visual Studio is not installed, its gives an error on startup
(Linking to MFC42D.dll failed). But it runs fine on computers having
VStudio installed. Please Tell me how can I make my application
portable.
Secondly, in my application(MDI) I want to create a new child window
when i click a certain menu item in my main menu (like in File->New)
where I can display a graph. Please tell me how I can a create a new
child window and use it.
Thanx in advance,
Rishabh Tag: memory allocation Tag: 279306
How to check dll version?
Hi,
I have got a vc6.0 project from my coleague. There are many dlls in this
project and export many functions. So in the main application, there are
bunch of "GetProcAddrss". I don't this kind of style.
I have a little knowledge of COM but do not have many experience, so I don't
want to use COM.
I want to export a class for every dll. The code like below:
//public interface file
class IHardwareInterface{
public:
virtual DWORD GetHost()=0;
virtual DWORD AddHost()=0;
...
};
extern "C" __declsepc(dllexport) IHardwareInterface* CreateInstance();
//implement file
class CHarewareImpl : public IHardwareInterface
{
...
};
Now, if in main application, I only need to create an interface for every
dll. I don't have to write bunch of "GetProcAddess". If I want to add more
export functions, I should update the interface class. What I worried about
is if I use the old dll, main application will not report any errors when
call "CreateInstance". It will report an error when I call the new function.
Is there any method to check whether the dll is consistent with the
interface file?
Any advice is appreciated. Thanks in advanced. Tag: memory allocation Tag: 279303
is this statement correct?
strstream s;
s << "var%05lX" << operand << '\0';
result:
s ==> var%05lXoperand
Thanks
Jack Tag: memory allocation Tag: 279296
MMX registers
I was just wondering if there is a way to tell Visual Studio to use
the MMX registers to improve performance.
Thanks. Tag: memory allocation Tag: 279295
excerpt from lecture notes help
hey all,
http://www.difranco.net/cop2334/Outlines/fileproc.htm
there's a section called:
Writing Data Randomly to a Random-access File
can you make it write plain text to the text file and still make all the
random stuff work? what do you need to changed to make it write as plain text
instead of binary?
thanks,
rodchar Tag: memory allocation Tag: 279275
Structure size
I would like to allocate a structure size of 1024 bytes but I want the
compiler to do the calculation for me.
typedef struct
{
int var1;
short var2;
long var3;
char var4[ ?????? ];
} MYSTRUCT;
What I want to do is replace the ?????? something that will automattically
make the total structure 1024 bytes without having to manually count the
bytes of the other members myself.
Is that possible in vc++?
Thanks. Tag: memory allocation Tag: 279273
Basic terminology help
hey all,
what's the difference between an API and a library of functions such as MFC?
Are these terms synonomous?
thanks,
rodchar Tag: memory allocation Tag: 279266
Petzold's tome
hey all,
i started my reading of Programming Windows and have a newbie question about
the following excerpt:
Microsoft Windows version 3.1 was released in April 1992. Several
significant features included the TrueType font technology (which brought
scaleable outline fonts to Windows), multimedia (sound and music), Object
Linking and Embedding (OLE), and standardized common dialog boxes. Windows
3.1 ran only in protected mode and required a 286 or 386 processor with at
least 1 MB of memory.
The last sentence is my question what does that mean in lamen's terms to run
in protected mode?
thanks,
rodchar Tag: memory allocation Tag: 279259
Managed C++ changing a forms property (Text)
Hey,
I'm working more with C++ nowadays (Creating host managers for a game,
and i need the asm functionality to get it all working.
I am trying to do (from frmAttach), changing the Text property of
frmMain ---- i am from VB, so i have tried frmMain.Text, frmMain().Text,
frmMain::Text, etc.
How would i achieve this?
Cheers Tag: memory allocation Tag: 279254
get the idle time of an excel application
I need to get the idle time of an excel application that is opened
through VC++.
Once the excel is opened there should be a timer that starts and it
should re start when ever there is some activity in the excel and if
the excel is ideal for about 15 mins then there should be a pop up
message Tag: memory allocation Tag: 279244
Compiler optimization problem in MSVC 2003 Release mode
Hi,
I have written a small function to check whether a single precision
variable is sufficient to hold a double precision value. The code is
below
#include <stdio.h>
int cmpFloat_to_Double(float x, double y) { return x == y;}
#define IsSinglePrecisionSufficient(a) cmpFloat_to_Double((float)a, a)
void main( void )
{
double b = 0.7;
printf("%d",IsSinglePrecisionSufficient(b));
}
It works fine in debug mode giving output of 0 but in release it gives
1. Also if i change
int cmpFloat_to_Double(float x, double y) { return x == y;}
to
int cmpFloat_to_Double(volatile float x, volatile double y) { return x
== y;}
it works fine in release mode too.
Thanks
Shireesh Tag: memory allocation Tag: 279235
I was just wondering if there is a way to specify in Visual C++ that a
memory allocation
be double quadword aligned.
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
<mike7411@gmail.com> wrote in message
news:1185488572.267304.241070@d55g2000hsg.googlegroups.com...
>I was just wondering if there is a way to specify in Visual C++ that a
> memory allocation
> be double quadword aligned.
>
> Any help is appreciated.
>
> Thank you.
>
"mike7411@gmail.com" <mike7411@gmail.com> wrote:
>
>I was just wondering if there is a way to specify in Visual C++ that a
>memory allocation
>be double quadword aligned.
You can always do arbitrary alignment yourself. To get 16-byte alignment,
just allocate a block 15 bytes larger than you need and round the pointer
up to the closest 16-byte alignment.
Just remember to undo the offset before freeing.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
"Tim Roberts" wrote:
> You can always do arbitrary alignment yourself. To get
> 16-byte alignment,
> just allocate a block 15 bytes larger than you need and
> round the pointer
> up to the closest 16-byte alignment.
>
> Just remember to undo the offset before freeing.
Yes, this is what `_aligned_malloc' actually does.