Using precompiled headers with C and C++
Hi,
Ive got a project which contains mixes of C and C++, and before you
suggest renaming the files, i cant ;).
Basically, i need a way of speeding up the compile time because its
horrendously slow, for our C++ projects, precompiled headers are a godsend.
Ive tried creating the following header file (incorrectly):
// C Includes
#if !defined(__cplusplus)
extern "C"
{
#include "main.h"
#include "error.h"
#include "acorn.h"
#include "pri.h"
#include "gra.h"
#include "car.h"
#include "mod.h"
#include "win.h"
#include "vie.h"
}
#endif
// C++ Includes
#if defined(__cplusplus)
#endif
But obviously, as this is always included from StdAfx.cpp it will always
be compiled as a C++ header.
So, how can i get my C files to include this precompiled header
successfully?
Any help on this would be much appreciated!
Cheers Tag: SSE compiler intrinsics slow when not optimized. Tag: 247958
Graphics Vanish when Window is Over
Greetings!
I am developping a multiple forms Windows Forms application in Visual
Studio C++ .NET 2003 and I need to draw graphics into a group box. In
order to do this I use:
private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e) {
Graphics* graph= Graphics::FromHwnd(this->groupBox1->Handle);
graph->DrawLine(new Pen(Color::Blue),20,20,50,50);//whatever...
}
It works. But the problem is: when I minimize and maximize again the
window, or when I put any window over my graphic, it vanishes! What
could I do in order to make the graphics stable?
If anybody could help anyway, I thank very much. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247952
Dialog in DLL - plain win32
Dear All,
This may be an age-old question, but I'm having trouble loading a dialog
from a DLL and haven't been able to find any solutions on the internet.
In my DLL, i have a dialog resource, and I create a modal dialog box using
win32 API's DialogBox() function.
In the executable, when I call the DLL function that loads the dialog box,
only the controls of the dialog box appears, but the frame itself doesn't.
Would someone please help me out on this one? Thank you so much!
Regards,
isa Tag: SSE compiler intrinsics slow when not optimized. Tag: 247950
cannot convert from 'System::String' to 'LPCSTR'
I am trying to use Managed C++ to get the dir from which my .msi was
launched and set a property with that value. I am pretty lost. I have no
clue if I am even on the right track, but this all seems so simple. Right
now the last line below - I can't get the 3rd arg right. It needs to be an
LPCSTR.
String *cdromDir = NULL;
if ((status = getInstallProperty(hInstall, "OriginalDatabase",
&imageLocation)) != ERROR_SUCCESS) return status;
cdromDir = Path::GetDirectoryName(imageLocation);
USES_CONVERSION;
MsiSetProperty(hInstall, "CDROMDIR", A2W(*cdromDir));
Thanks,
owen Tag: SSE compiler intrinsics slow when not optimized. Tag: 247944
what's the different between #incldue " xxx" and #include <xxx >
Hi All,
When we include a header file, we will use
#include "xxx "
or
#include "xxx"
What's the difference?
Best regards,
Boki. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247943
System Class initialization complete?
Hi,
I have a class that has an initialization thread spun up by a static member.
I don't want this thread to run until *all* the classes are done
initializing. How can I tell when all the classes (mine and MFC's) are done
initializing and it's safe to start creating instances of my classes?
Thanks... Tag: SSE compiler intrinsics slow when not optimized. Tag: 247936
Displaying Grayscale Images
How do I display Grayscale Images from a file using VC?
Thanks Tag: SSE compiler intrinsics slow when not optimized. Tag: 247934
Cannot instantiate abstract class
Why do I get C2259: 'Derived': cannot instantiate abstract class from
the following scenario?
class Abstract
{
public:
virtual int GetType() = 0;
virtual int GetApp() = 0;
virtual void GetVersion() = 0;
...
}
class Derived : public Abstract
{
public:
int GetType();
int GetApp();
void GetVersion(LPTSTR versio, size_t versionSize);
...
}
In class 'Derived' I've written an implementation for all three pure
virtual methods. Still the compiler claims the class 'Derived' is
abstract if I try to instantiate it??? Tag: SSE compiler intrinsics slow when not optimized. Tag: 247929
My first C++ Application in VC++ 2005 Express!
Dear All,
My name is Davin Eastley and I'm 13 years old. I wrote my first C++ 2005
Application yesterday with no resources by playing around with C++ Express
Edition for half the day. I assigned x as an int (with the value of 20) and
got the compiler to tell me whether it was greater than 2 or not. This was
the code I used:
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
int x;
x = 1;
//this assigns x as an int
//(a variable - data type -)
if (x >= 2)
{
// if x is greater than 2, output a messagebox saying x is greater than 2.
MessageBox::Show(L"x is greater than 2!");
}
if (x < 2)
{
// if x is lower than 2, output a messagebox saying x is lower than 2.
MessageBox::Show(L"x is lower than 2!");
}
}
This is straight from the compiler. This is the new style of C++ 2005. I am
very happy to write my first application in C++. I also wrote a console
application which uses Console::WriteLine instead of the messagebox
equivalent. I still want to know how to use the cout and cin keywords
though. Time to do some more learning on C++!
Regards,
Davin Eastley
--------------
www.davineastley.tk
Forums Home Tag: SSE compiler intrinsics slow when not optimized. Tag: 247926
Calculate the length of a MIDI file
My app opens a midi file using the MCI api. how to retrieve the length of
the MIDI in seconds? The MCI_STATUS_LENGTH status command returns a number,
but how to convert it to seconds?
thanks Tag: SSE compiler intrinsics slow when not optimized. Tag: 247924
Question about import directive
I want to learn more about how the import directive works. I just used
for the first time recently with the vbscript regex com object. I
googled the import directive but I couldn't find alot of information on
the import directive just its usage in specific cases. I wanted to ask
if anyone knew of any books or websites that explain more about import
directive. Thanks
Danny Tag: SSE compiler intrinsics slow when not optimized. Tag: 247918
Stack Overflow
Hi All,
What cause a Stack Overflow?
Is it that the program used more memory than that was alloted for it?
I converted my application to Unicode and it statredgiving this problem.
It's not getting stuck in an infinite loop, and if I step into it, it's not
getting stuck at any particular line which is alotting any memory, it crashes
at the beginning of a function. Maybe since I converted all those chars to
TCHARs now it's using up double the memory, and running out of memory????
Plese enlighten me
Thanks a lot in advance
Srishti Tag: SSE compiler intrinsics slow when not optimized. Tag: 247914
Cannot delete a memory mapped file at end of program
Hi All,
wonder if someone can point out what I am doing wrong.....I am creating
memory mapped files on win2000 using CreateFile and CreateFileMapping
and MapViewOfFile. At the end of the program I figured it would be
nice to clean up these files but when I issued the del <filename> as a
system command (or if I try the DeleteFile function) I get a message
saying that the file is in use by another process.....Is there
something else I must do to release a file that I have set up using
CreateFile and CreateFileMapping and MapViewOfFile???
Any tips greatly appreciated...
//////////////////////////////////////////////////////////////////////////////////////////////
// When the job ends deleted the wait file, the kill file, and any
memory mapped files that //
// have been created by this process.
//
//////////////////////////////////////////////////////////////////////////////////////////////
ptr_WaitFile->Delete() ;
ptr_KillFile->Delete() ;
for (index1 = 0 ; index1 < ws_used_memory_mapped_files ; index1++)
BEGIN_
#if defined (_MSC_VER)
UnmapViewOfFile(ptr_MemMapBuffer_array[index1]) ;
DWORD dw1 = GetLastError();
CloseHandle(ws_HandleForMemMapFile_array[index1]) ;
DWORD dw2 = GetLastError();
#endif
ptr_DimensionTable_File[index1]->Delete() ;
END_ Tag: SSE compiler intrinsics slow when not optimized. Tag: 247899
Black drag image
I am using WTL and getting a blackbox for my drag Image.
Any help greatly welcomed.
CImageList *m_pDragImage = new CImageList();
<OnBeginDrag>
m_pDragImage->Create(16,16,ILC_COLOR16 ,0,10);
CBitmap bm;
bm.LoadBitmap(IDB_DRAGIMAGE);
m_pDragImage->Add(bm,RGB(0,0,0));
m_pDragImage->BeginDrag(1, CPoint(nOffset, nOffset));
m_pDragImage->DragEnter(m_hWnd, a->ptAction);
<OnMouseMove>
m_pDragImage->DragShowNolock(TRUE);
m_pDragImage->DragMove(pt); Tag: SSE compiler intrinsics slow when not optimized. Tag: 247892
Generating makefile dependencies
Hi,
Many compilers have a command-line option, usually -m or -M, to generate
dependencies for inclusion in a makefile. Does any version of the VC++ compiler
support such an option?
I know it used to be possible to do it through the IDE and that this feature was
abolished; I'm just interested in command-line options.
Best,
Jonathan Tag: SSE compiler intrinsics slow when not optimized. Tag: 247888
Best way to handle SEH and COM Exceptions
Not sure if this is the right section of the forums to post but here goes.
I work as an escalation engineer and we have an application that is using VB
and C++ dll. The VB app passes in some XML to the C++ code which calls a
database using ADO with the #import statement. The #import looks like this:
#import "C:\Program Files\common files\system\ado\msado15.dll" no_namespace
rename("EOF","adoEOF")
If I understand everything the #import statement generates some .tlh and
.tli files that wrap ADO. Also adding error handling by calling
_com_raise_error which throws internaly _com_errors.
My problem is this. The app is throwing (maybe better to say raising) an
exception inside a C++ try block that was being eaten by the catch(...). Not
good because we are losing the exception. So I removed the catch(...) and
added a SetUnhandledExceptionFilter( HandleCrash ) in the DLLMain. When the
HandleCrash exception filter is call I call MiniDumpWriteDump which seems to
be working fine.
Is this good programming practice and will it produce the most reliable
code? When the HandleCrash is call I believe the only thing I can really do
is write a minidump and end the program. Is this write? And now the code :)
Thank you in advance for your help!
// in dllmain
SetUnhandledExceptionFilter( HandleCrash );
//
LONG WINAPI HandleCrash( LPEXCEPTION_POINTERS pExs ) {
// format file name app and date time of dump
FormatFileName( _T("app"), _T(""), file );
// message box to tell user they crashed and dump file has been writen
::MessageBox(...
// dump minidump
HANDLE hFile = CreateFile( file, GENERIC_READ | GENERIC_WRITE, ...
if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) ) {
MINIDUMP_EXCEPTION_INFORMATION mdei;
mdei.ThreadId = GetCurrentThreadId();
mdei.ExceptionPointers = pExs;
mdei.ClientPointers = FALSE;
MINIDUMP_TYPE mdt = MiniDumpNormal;
BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
hFile, mdt, (pExs != 0) ? &mdei : 0, 0, 0 );
if( !rv )
_tprintf( _T("MiniDumpWriteDump failed. Error: %u \n"), GetLastError() );
else
_tprintf( _T("Minidump created.\n") );
// Close the file
CloseHandle( hFile );
} else {
_tprintf( _T("CreateFile failed. Error: %u \n"), GetLastError() );
}
return EXCEPTION_EXECUTE_HANDLER;
}
try
{
// setup connection...
hr = pConnection.CreateInstance( __uuidof(Connection) );
// ... code and error checking removed for breviety ...
// setup command and parameters ...
hr = pCommand.CreateInstance( __uuidof(Command) );
// ...
// exception occuring here
hr = pCommand->Execute( NULL, NULL, adExecuteStream );
// ...
} catch( _com_error &e ) {
// log error in log file and continue...
} catch( std::exception& e ) {
// log error in log file and continue...
}
// this was originally in the code
// but was removed because the exception was being lost
catch( ... ) {
//do nothing :(
} Tag: SSE compiler intrinsics slow when not optimized. Tag: 247876
C v6.0 Compiler Needed
I have been asked to modify a Microsoft C v6.0 program written in 1991.
However, I do not have a Microsoft C compiler.
Does anyone know where a C compiler can be obtained? Will any of the MS
Visual Products work? Tag: SSE compiler intrinsics slow when not optimized. Tag: 247870
WriteFile reports x bytes written, but file does not grow
Folks,
I'm not quite sure if this is the correct newsgroup to post it, but I'm sure
there are experts here that might have an answer to my question.
I have developed a .net isapi DLL (Web Service) that uses a COM object to
cut and merge WAV files.
Now, the Web Service and the COM object work fine on my XP machine, writing
the file as it should.
However, when I run the complete system on a Win2000 machine, my writefile
in the COM object acts strangely.
It should write some buffer to a file, and the BytesWritten returns exactly
the number of bytes that need to be written, but my file does not grow. I'm
offering a total amount of 20 MB to write (in 4096 kB buffers) but the file
stays 1 kB. This 1 kB is from a previous WriteFile action that writes a WAV
header to the file.
So, after writing the wave header, every call to writefile does not result
in file growth.
Does anyone have similar experience or has seen this kind of behavior
before?
I appreciate any response.
Thanks in advance!
Rob Vermeulen. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247869
how to convert "ff" (string) to integer 255
for (jjj = 0; jjj < argc-2; jjj++)
{
itemsg[jjj] = atoi (argv[jjj+2]);
}
static int jjj;
int itemsg[200];
itemsg[jjj] always becomes not...
Pls help...
Jack Tag: SSE compiler intrinsics slow when not optimized. Tag: 247865
Sharing violationin fopen function with "w" flag
Hi,
I have a a application developed in Visual C++ 6.0. It is running very well
in Windows 2000 platform but in XP I have got some random problems. I have
been testing and I have seen, I think, that the problem is in fopen function.
I am running VMWare machine with XP Pro Service Pack 2. The VMWare is
running on Windows 2000. The files are in Windows 2000 and I read the filed
trought the net.
If I run the same application in Windows 2000 there is not problem. It run OK.
The problem is follow: When I call the fopen function in a exact pont,
sometimes the system going to down and slowly and when the system return the
file hanlde, sometimes return OK and sometimes return 0x00000. I have use the
"filemon" tool and, in this situation, the filemon shows: "Sharing violation
error"
Also, I have compared the systems calls with filemon in W2k and XP and I hav
seen that the fopen funtion, in W2k, make a "Query" call but in XP not.
I have spent very time in order to discover the problem but I have not seen
the solution.
Also I have installed several hotfixes after the SP2.
Thanks. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247864
StreamOut doesn't preserve CFM_LINK settings
Hi Everybody,
In my rich edit application, I just discovered CFM_LINK and am enjoying
having clickable links in my CRichEditCtrl. However, when I use
streamOut and streamIn to save my control contents to disk and back,
all the RTF formatting is preserved except for the links. Please guide
me how to save the RTF document along with the hyperlink.
Regards,
Prakash. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247863
Why this error "error C2146: syntax error : missing ';' before identifier 'Length'"
I have a VC++.net Win32 console application, however when I compile , I
get this error
error C2146: syntax error : missing ';' before identifier 'Length'
Explain...
Location pointed is
typedef struct _LIST
{
LPLINK Tail; //... List Tail pointer.
LPLINK Head; //... List Head pointer.
DWORD Length; //... List Length.
} LIST;
typedef LIST *LPLIST;
in List.h
Thanks,
a.a.cpp Tag: SSE compiler intrinsics slow when not optimized. Tag: 247860
outportb available?!?!?
Hi there,
I would like to create a .dll from legacy code. It includes the inportb and
outportb commands. Are inportb and outportb available in any version that
can create a dll??
Thanks very much,
Russ Tag: SSE compiler intrinsics slow when not optimized. Tag: 247855
From Borland C++ 502 to Visual C++
HI,I need help!!! I've the source code of a software written with
Borland C++ 5.02 IDE. I want to port this code from Borland C++ 502 to
Visual C++ 6. Is this possible?? Do you have any advice for me??
Thank's for All
Jasp Tag: SSE compiler intrinsics slow when not optimized. Tag: 247850
Moving from C++ to VC++
Hi all.
Are there any good web tutorials that teach how to make this move? I
don't necessarily need to know MFC inside and out, as MSDN is
sufficient for that. Code conventions, MS typedef's that should be
used (DWORD for example), and other things that accomplish the same
thing in C++ but in VC++ style. I'm a good C++ coder, but my VC++ apps
seem to be lacking when I peruse the code presented in this NG. Any
help is very much appreciated.
Thanks,
Mike Tag: SSE compiler intrinsics slow when not optimized. Tag: 247849
Control X10 devices + a/v equipment with Bluetooth mobile phone
Pluto is a free, open source smart home solution that seamlessl
integrates: 1) media with a server for music, movies and tv shows, plu
a PVR and DVD Player, 2) a home automation system with touch-scree
tablet and Bluetooth mobile phone controllers, 3) a phone system wit
video conferencing, 4) a security system that feeds you live video o
your mobile phone when there are interruptions, and lets you speak t
visitors through your stereos, and 5) a home PC solution. Check it ou
at [url]www.plutohome.com[/url]
It lets you control your X10 devices with the PC, webpads, pdas an
mobile phones, using both scenario shortcuts and interactiv
floorplans
-
laura
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: SSE compiler intrinsics slow when not optimized. Tag: 247848
Member template internal compiler error
I am getting an Internal Compiler Error in VC++ 6 with the following code.
I'm fairly sure it is well-formed (g++ 3.4.2 compiles it fine). Is there a
workaround available?
#include <iostream>
#include <ostream>
class Foo
{
public:
template <int N>
static void Test()
{
std::cout << N << std::endl;
}
};
int main()
{
Foo::Test<5>(); /* I.C.E. here */
}
Thanks for any help you can provide.
Kristo Tag: SSE compiler intrinsics slow when not optimized. Tag: 247846
cin.read() failure
Hello All,
I'm having some trouble with cin and ifstreams while reading some binary
data. Everytime I read in character #10 (Line feed,) the stream fails,
and I am unable to read any further from the stream, even if I use
cin.clear() or cin.peek().
What can do to be able to read past a Line Feed?
-Joel Tag: SSE compiler intrinsics slow when not optimized. Tag: 247843
Capturing the save click events in Microsoft word.
I want to develop an application using MSAA in which I want to trace
when a user presses some menu items - like save, print, save as etc.
What are the events related to that. For menu open
EVENT_SYSTEM_MENUSTART types of event are available but what are the
events related to pressing the save , print , save.
Regards,
Sunil Virmani Tag: SSE compiler intrinsics slow when not optimized. Tag: 247841
allocator question
Hi to all,
when passing an allocator to SEVERAL containers at the same time, can we
rely on the "rebind" mechanism assuming that each container is able to
select its own allocator?
for example: is the following ok?
template <class T, class allocator_t>
class MyContainer
{
std::vector<T, allocator_t> v_;
std::map<T, int, std::less<T>, allocator_t> m_;
};
or should we be verbose and deduce the correct allocators out of the
sub-containers:
template <class T, class allocator_t>
class MyContainer
{
typedef typename allocator_t::template rebind<T>::other rebind1_t;
std::vector<double, rebind1_t> v_;
typedef typename allocator_t::template rebind< std::pair<const T,
int>::other rebind2_t;
// etc...
};
of course version #1 and version #2 declare a class whose members have
different types (say, m_ is map<T,int, ... allocator<T> > and map<T,int, ...
allocator< std::pair<...> > >), but apart from that, are they "functionally"
equivalent? Tag: SSE compiler intrinsics slow when not optimized. Tag: 247840
Files in current directory
Which API(s) or C/C++ library functions can retrieve all the names of the
files in a directory?
Thanks
Jack Tag: SSE compiler intrinsics slow when not optimized. Tag: 247828
Console App - howto determine if an app is a console app
How can I find out if an application is a console app or a windows app.
I realize that if there the header starts with 0xd4 0x5a it cannot be
run in "DOS" mode but that not mean a windows 2000 console app. I have
win2k console apps and they also start with 0x4d 0x5a.
thanks for the help
john Tag: SSE compiler intrinsics slow when not optimized. Tag: 247827
parsing command line args in CDialog app
Hi,
I have a CDIalog MFC based win ap under MSVC 6.0
Now I need to configure it for parsing command line parameters ,,,,
where and which function does accept argc, char** argv as there is no
main()
Kindly help
Thanks,
a.a.cpp Tag: SSE compiler intrinsics slow when not optimized. Tag: 247817
question about retrieving a volume name...
i am trying to determine the volume name for each partition on a physical
disk resource in a mscs environment.
i have already established the ability to enumerate all of the storage
resources and get a CLUSPROP_PARTITION_INFO structure for each.
when i retrieve the szdevicename property of the structure i get a drive
letter for all volumes mounted to a drive letter. i can uset
findvolumenameformounpoint by simply appending a \ to the string to get the
volume name.
however volumes that are mounted to a folder or not at all return a string
similar to Disk1Partition4 for their szdevicename. are there any functions or
proceedures i can use to retrieve the volume name only knowing the above
mentioned string?
my searching has turned up nothing. thanks for your help!!! Tag: SSE compiler intrinsics slow when not optimized. Tag: 247809
unresolved external symbol __abs64
Is _abs64 not available in the DLL libraries?
I am using Visual Studio 2003. A program that uses the _abs64 function
links fine with the multithread debug (/MTd), but not multithread debug dll
(/MDd). Is this a bug or by design? Tag: SSE compiler intrinsics slow when not optimized. Tag: 247808
should i do SysFreeString here?
i'm just doing some wrap class for msxml and got some problem?
i'm using the raw interface in msxml.h, not smart pointer. (visual studio
2003)
sample code like this:
//--start-------------------------------------------
{
IXMLDOMDocument* pDoc = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**) &pDoc);
hr = pDoc->put_async(VARIANT_FALSE);
hr = pDoc->put_validateOnParse(VARIANT_FALSE);
hr = pDoc->put_resolveExternals(VARIANT_FALSE);
CComVariant varFile(_T("c:\\aa.xml"));
VARIANT_BOOL status;
hr = pDoc->load(varFile, &status);
BSTR bstrXML = NULL;
pDoc->get_xml(&bstrXML);
//***********************
// doing some processing for bstrXML;
// ...
//
SysFreeString(bstrXML); //should i do SysFreeString here?
//***********************
pDoc->Release();
}
//--end---------------------------------------------
i have used _CrtDumpMemoryLeaks() and
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF )
to detect memory leak.
but whether i do SysFreeString or not, there is no memory leak detected.
i believe use SysFreeString() here is a good behave.
and i have viewed some code from others. someone use, someone not.
i am very confused that is it necessary to do SysFreeString here?
and anyone can help me?
thanks! Tag: SSE compiler intrinsics slow when not optimized. Tag: 247807
Theoretical Question
A colleague posed an interesting question to me today.
In C or C++, why can't I write this:
void MyFunction() {
unsigned var : 14;
// ...
}
The compiler already knows how to do the shifting and masking for bit
fields in structures. The above is nothing more than syntactic sugar for,
say:
void MyFunction2() {
struct {
unsigned f : 14;
} var;
// ...
}
But I could think of no good reason why the first one couldn't also be
done, and there are certain problem domains where that kind of thing could
prove useful.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc Tag: SSE compiler intrinsics slow when not optimized. Tag: 247789
COM question
This might be considered an elementary question for those with COM
emblazened upon their belt buckles, but I know just enough about it to be
dangerous! Here goes...
If I include <dskquota.h>, I can use the following code just fine:
IDiskQuotaControl *lpDiskQuotaControl;
IEnumDiskQuotaUsers *lpEnumDiskQuotaUsers;
HRESULT hr = CoCreateInstance(CLSID_DiskQuotaControl,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDiskQuotaControl,
(LPVOID*)&lpDiskQuotaControl);
if (SUCCEEDED(hr))
{
hr = lpDiskQuotaControl->Initialize(_bstr_t("c:\\"), TRUE);
if (SUCCEEDED(hr))
{
hr = lpDiskQuotaControl->CreateEnumUsers(NULL, 0,
DISKQUOTA_USERNAME_RESOLVE_SYNC,
&lpEnumDiskQuotaUsers);
...
}
lpDiskQuotaControl->Release();
}
If, however, I wanted to use smart pointers instead with #import
<dskquota.dll> then the CreateEnumUsers() method does not show up in the
.tlh or .tli file. There also does not appear to be an interface for the
users (plural). Is it supposed to be this way, or what am I doing wrong?
Thanks,
DC Tag: SSE compiler intrinsics slow when not optimized. Tag: 247788
How to get selected files Filename and full path?
Hi,
i am working on a kind of protection application that
must react when a user selects (only hover resp. mark, not execute!) a file
that in turn will be market as selected. I
need to find out the files full path and name. How can i
do this. Is there a WM_ Message or equal available
for this? Systemwide Windows Hook?
How can this be accomplished.....? :-)
Thanks in advance...
Kerem Gümrükcü Tag: SSE compiler intrinsics slow when not optimized. Tag: 247765
::exception
Hi,
Someone can explain to me the diference between CODE_A and CODE_B?
//double calc( int a, int b ) ;
//double calc( int a, int b ) throw(MathError);
why "throw(MathError);"
CODE_A
--------------------------------------------------------------
class MathError
{
private:
string message;
public:
MathError( const string& s) : message(s) {}
const string& getMessage() const {return message;}
};
double calc( int a, int b ) throw(MathError);
int _tmain(int argc, _TCHAR* argv[])
{
int x, y; bool flag = false;
do
{
try // try block
{
cout << "Enter two positive integers: ";
cin >> x >> y;
cout << x <<"/"<< y <<" = "<< calc( x, y) << '\n';
flag = true; // To leave the loop.
}
catch( MathError& err) // catch block
{
cerr << err.getMessage() << endl;
}
catch( ...)
{
cerr << "3333" << endl;
}
}while( !flag);
// continued ...
return 0;
}
double calc( int a, int b ) throw (MathError)
{
if ( b < 0 )
throw MathError("Denominator is negative!");
if( b == 0 )
throw MathError("Division by 0!");
return ((double)a/b);
}
CODE_B
--------------------------------------------------------------
class MathError
{
private:
string message;
public:
MathError( const string& s) : message(s) {}
const string& getMessage() const {return message;}
};
double calc( int a, int b )
int _tmain(int argc, _TCHAR* argv[])
{
int x, y; bool flag = false;
do
{
try // try block
{
cout << "Enter two positive integers: ";
cin >> x >> y;
cout << x <<"/"<< y <<" = "<< calc( x, y) << '\n';
flag = true; // To leave the loop.
}
catch( MathError& err) // catch block
{
cerr << err.getMessage() << endl;
}
catch( ...)
{
cerr << "3333" << endl;
}
}while( !flag);
// continued ...
return 0;
}
double calc( int a, int b )
{
if ( b < 0 )
throw MathError("Denominator is negative!");
if( b == 0 )
throw MathError("Division by 0!");
return ((double)a/b);
}
Thanks Tag: SSE compiler intrinsics slow when not optimized. Tag: 247760
sending message from UI thread to the main thread
I have a main control in which I have a loop which processes video
frames. To be able to see the results in real time, I created a dialog
in another thread which displays the data as they become available (the
main thread populates a global array, and the second thread picks the
last element and displays it.)
I need to access some functions (e.g. change settings of video
aquisition) in the main thread from within the second thread while the
loop in the main thread is running. I know I have to use messages to do
that, but SendMessage needs a pointer to the main window, and I can't
pass a CWnd * to the secondary thread.
So, how do I call a main thread function from a secondary thread?
Here's a sketch of what I have now:
//in main control:
pThread = (CUIThread*)AfxBeginThread(RUNTIME_CLASS(CUIThread));
pThread->m_pMainWnd = FromHandle(this->m_hWnd);//this does not work
//in UIThread class:
CUIThread::InitInstance()
{
CWnd * cwnd = m_pMainWnd;
m_plot = new Plot_dialog(cwnd);
return TRUE;
}
//in Plot_dialog:
Plot_dialog::Plot_dialog(CWnd* pParent) {}
Plot_dialog::UpdateSetting() {
pParent->SendMessage(WM_PLOT_TO_MAIN, 0, (LPARAM) &CCM);
} Tag: SSE compiler intrinsics slow when not optimized. Tag: 247759
How to modify CString in the debugger for VC6.0?
How can a CString variable be modified in the debugger with VC 6.0?
For instance I want to change "xxx" to "" so that I can test a certain code
path.
Thanks. Tag: SSE compiler intrinsics slow when not optimized. Tag: 247754
memory allocation problems
Hello,
this is probably most fundamental but I don't code in C++ often and I'm just
not getting why the code is crashing with a:
Unhandled exception at 0x77f75a58 in FileIOTest.exe: User breakpoint
I have a function that calls this line of code:
char* buffer = new char[sizeof(char) * (strlen(curtime) + strlen(msg) + 3)];
The first time I call the function, all is well but subsequent times it
crashes with the above exception. All I'm doing is a strcpy, strcat and
writing to a file in the funciton and then I delete buffer memory using
delete.
What could the problem be. Sorry is this is just really stupid...
Steve Tag: SSE compiler intrinsics slow when not optimized. Tag: 247739
Converting a 4 byte char to a double
Hi there,
I'm trying to convert the 4 bytes returned by a time server to a double
value, I know this should be pretty straight forward but I think I have gone
wrong somewhere along the lines.
At the moment I am doing the following
string pStrBuffer;
<pStrBuffer is now assigned the value>
double pDblSeconds;
int pIntChar;
for(pIntChar=0;pIntChar<pStrBuffer.length()-1;pIntChar++)
{
double pDblCurValue = 0;
pDblCurValue = (int)pStrBuffer.c_str()[pIntChar];
pDblCurValue = ((int)pDblCurValue << (8*pIntChar));
pDblSeconds += pDblCurValue;
}
Unfortunately I am recieving 0 as my value at the moment. Any ideas on
what I'm doing wrong? Thanks laods in advance!
--
Nick Pateman
---------------------------------------------------------------
Any views expressed above are my own
Without predjudice Tag: SSE compiler intrinsics slow when not optimized. Tag: 247737
OT: How to search binary occurences in files
Hi,
In case I have a set of files to search in for a binary pattern (For example
FF A1 23 0a), is there any free software which can do this job? I don't want
to open a hell lots of files to search for the stream individually... cos it
takes ages to do so.... I have already about > 100 files to search in.....
sorry for OT question....
Thanks
Jack Tag: SSE compiler intrinsics slow when not optimized. Tag: 247736
Passing GET variables to a CGI script from C
Hi,
I'm trying to pass variables to a local web page (with JavaScript) from C.
I've tried to do this with ShellExecute and WinExec as follows:
ShellExecute(m_hWnd, "open",
"file:///c:/some_page.html?var1=some_val&var2=some_other_val", "", NULL,
SW_SHOWNORMAL);
... which opens up the browser and webpage correctly, but the query string
gets lost along the way.
I've also tried setting the QUERY_STRING environment variable prior to
loading the page, which doesn't work - I'm assuming it gets overwritten when
the page loads with no query string appended to the url.
Any suggestions?
Thanks,
-Nick Tag: SSE compiler intrinsics slow when not optimized. Tag: 247735
vector and debug mode
Hi
I am using vector class (via #include<vector>) as a dynamic array.
vector <int> list;
int array [10];
With the array definition I can se eg. the 7. element in the watch window in
the debugger (when execution has stopped due to a breakpoint or an
exception) by typing array[7].
This is not possible for the vector definition.
Is it possible to somehow circumvent this, so I can see eg. the 7. element
of the list in the watch window??
Any ideas would be welcome!
Regards,
Peter Stausholm Tag: SSE compiler intrinsics slow when not optimized. Tag: 247730
GetOpenFileName set to "My Computer"
How do I set the default location to "My Computer" when using the
GetOpenFileName call?
I have tried the following but CSIDL_DRIVES doesn't appear to work. Any
ideas?
WCHAR szFile[260] = _T("text.txt");
WCHAR szPath[MAX_PATH] = _T("");
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidl);
if(SUCCEEDED(hr))
SHGetPathFromIDList(pidl, szPath);
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("All\0*.*\0Text\0*.txt\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = szPath;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn)==TRUE) // File dialog Open selected
{}
--
--
mnlarsen Tag: SSE compiler intrinsics slow when not optimized. Tag: 247729
Of course, I know why this is. I was wondering if there's a way to get the
compiler to generate optimized code for these types of routines when doing
debug builds.