a language question about conversion operators
Hi,
I think I remember that template member functions do not trigger
user-defined conversions.
The code below in fact does not compile. instead if I remove the cast
operator from C and let C derive from A, it succeeds.
Is the explanation correct?
TIA,
MH
template <typename T>
struct A {};
struct B
{
template <typename T>
bool operator==(A<T>) const
{
return true;
}
};
struct C // : public A<int>
{
operator A<int>() const
{
return A<int>();
}
};
int main()
{
C c;
B b;
return b == c;
} Tag: overload "A<int>"?? Tag: 282856
WM_COPYDATA INFO
I need to drag and drop a contact from outlook to my
application....Can i do it using WM_COPYDATA???
OR
IS WM_COPYDATA BE USED ONLY WITH TWO APPS WHICH KNOWS EACH OTHER?
Thanks in advance,
John. Tag: overload "A<int>"?? Tag: 282833
VC BUG
The code has problem, but comiplie ok! link ok
void CMyDialog::OnOK()
{
extern CButton m_DLG1_IDOK_n; //m_DLG1_IDOK_n not exist
CButton m_DLG1_IDOK;
if(m_DLG1_IDOK_n.GetCheck == m_DLG1_IDOK.GetCheck) // Call function
without (), like vb
return;
CDialog::OnOK();
}
Envirment: XP + VC6.0 Tag: overload "A<int>"?? Tag: 282831
running C++ code with mutiple routines from matlab
I have written an image processing app in Matlab which works fine when
I analyze images one at a time, but is very slow when I have to
analyze thousands of images in a row. So I re-wrote the image analysis
routine in C++, compiled in .NET. The C++ code runs about 20 times
faster than Matlab. Being a layman in programming, I am now wondering
how to make matlab talk to C++.
The C++ code is a .cpp file and an .h file. The .cpp file contains ~5
functions that talk to each other, and the main() produces the final
answer. From what I understand to make a .dll I can export functions
one at a time - is that so? If yes, how can I make main () .dll talk
to the .dlls with the seconday functions and then report to matlab? Or
do I have to bundle all functionalities into the main()?
Or is making a .dll not the right way to go? Tag: overload "A<int>"?? Tag: 282827
Command line C compiler ignores /Za switch?
Hello,
I'm using VS2005 Pro on WinXP. I'd like to disable C language extensions,
such as allowing dollar signs in identifiers and allowing C++ style comments.
When I set the /Za switch in the IDE project properties it rejects these
extensions, as desired. However, when I use the command line compiler it
ignores /Za. Here's a sample command line (whose arguments/switches I copied
directly from the IDE, minus the debug file stuff):
cl /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0710" /D
"_MBCS" /Gm /EHsc /RTC1 /MTd /Za /W4 /nologo /c /Wp64 /ZI /TP
/errorReport:prompt MyProgram.c
Thanks,
Ray Mitchell Tag: overload "A<int>"?? Tag: 282824
Debug Control Panel App?
Hi: I have a cpl file for the control panel. Just wonder how do I debug it in
the Vidual Studio? Which exe should I specify as the caller of this cpl?
Thanks in Advance!
Polaris Tag: overload "A<int>"?? Tag: 282810
can the member function be compared?
for example, there is a class as below
struct Foo
{
void Func1()
{}
void Func2()
{}
};
As known, &Foo::Func1 != &Foo::Func2 is right, but &Foo::Func1 < &Foo::Func2
is illegal. So std::map< void ( Foo::* )() > can not be defined. Are there
some other ways to get the greater and less relationship between two member
functions?
Thanks! Tag: overload "A<int>"?? Tag: 282807
VC++ 6.0 workaround for partial specialization
Hello everyone,
I am working on a project on Visual C++ 6.0 and I need to port some code
that uses partial specialization of class templates:
#include <cstddef>
#include <iostream>
// Extracts the type of an object.
template <class T>
struct extract { typedef T type; };
// Extracts the type of an array.
template <class T, std::size_t N>
struct extract<T[N]> { typedef T type; };
// Primary template for object new.
template <class T> struct TrackNewHelper
{
static T* TrackNew( T* ptr, const char* file, int line)
{
std::cout << "Tracking object allocation" << std::endl;
return ptr;
}
};
// Partial specialization for array new.
template <class T, std::size_t N> struct TrackNewHelper<T[N]>
{
static T* TrackNew( T* ptr, const char* file, int line)
{
std::cout << "Tracking array allocation " << std::endl;
return ptr;
}
};
// Forwards the call to helper classes.
template <class T> typename extract<T>::type* TrackNew(
typename extract<T>::type* ptr, const char* file, int line )
{
return TrackNewHelper<T>::TrackNew( ptr, file, line );
}
#define NEW( T ) TrackNew<T>( new T, __FILE__, __LINE__ )
int main()
{
int * p = NEW( int ); // Calls the primary template.
delete p;
p = NEW( int[64] ); // Calls the partial specialization.
delete [] p;
return 0;
}
I found a hint on the internet saying that class member templates can
simulate partial specialization, but unfortunately, no further information
was given. Does anyone happen to know a workaround for the code above?
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers Tag: overload "A<int>"?? Tag: 282799
Find the MAC address of NIC when the network connection is disabled.
Hi all,
I need to programmatically find the MAC id of the NIC when the network
connection is disabled.
The scenario is like this. You have multiple NICs on your PC. Now you
go
the network connection applet and disable one of the connection. Now
if you issue getmac command from command prompt, the mac ID of the
disabled connection will not be listed. I want to get this ID
programmatically. I tried some WMI methods and GetAdaptersAddresses
function to no avail.
Is this task possible?
Thanks in advance,
Shaji. Tag: overload "A<int>"?? Tag: 282797
How can LoadLibrary fail?
I have a project which attempts to load a DLL with
HINSTANCE hInstance = LoadLibrary( pszPath );
where pszPath is the full path name of the DLL.
Just occasionally it fails and returns NULL. It has done it for others,
but just this week it happened to me for the first time, and so i was able
to check one or two things.
The path is correct and the DLL is there.
The path name is not longer than _MAX_PATH characters.
The library in question is a resource-only DLL which has one C++ function in
a .cpp file which reads in its entirety:
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
How can it fail?
[In my case rebuilding the resource-only DLL made it work again, but this
does not necessarily work for others with the problem, and so I need to
understand what can go wrong!]
A bit more detail:
Immediately prior to attempting to load the DLL I do a loop using
FindFirstFile() FindNextFile() [and I don't forget FileClose()] to store a
collection of names of resource DLLs which are present (all of the above
content), and have names of a certain form. Then I try to open each one of
them, and extract a string from it with a given ID, which tells me more
about it. But sometimes, just occasionally, one or more fails to open.
[The calling DLL is linked dynamically with MFC and using AfxLoadLibrary()
makes absolutely no difference.]
Any ideas?
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm Tag: overload "A<int>"?? Tag: 282795
Who can explain this code for me?about virtual function
///////////////////////////////////////////////
// CIOMessageMap.h
class __declspec(novtable) CIOMessageMap
{
public:
virtual bool ProcessIOMessage(IOType clientIO, ClientContext*
pContext, DWORD dwSize) = 0;
};
#define BEGIN_IO_MSG_MAP() \
public: \
bool ProcessIOMessage(IOType clientIO, ClientContext* pContext, DWORD
dwSize = 0) \
{ \
bool bRet = false;
#define IO_MESSAGE_HANDLER(msg, func) \
if (msg == clientIO) \
bRet = func(pContext, dwSize);
#define END_IO_MSG_MAP() \
return bRet; \
}
Why class CIOMessageMap should be declared by declspec(novtable)?
The macros implements the member function of CIOMessageMap --
ProcessIOMessage();But in other places of project,there no any
inheritances of CIOMessageMap.
Who can tell me the advantages about this coding style?
There are will best in detail. Tag: overload "A<int>"?? Tag: 282791
Self deleting class
Hi,
Imagine:
CSomeClass* c = NULL;
c = new CSomeClass();
delete c;
c = new CSomeClass();
delete c;
So I must call delete c; to clean up memory.
However, instead of doing it like so.. isn't it equally valid to make class
self deleting?
So, if I do this:
class CSomeClass
{
CSomeClass();
virtual ~CSomeClass() { delete this; }
}
can I then simply do this?
CSomeClass* c = NULL;
c = new CSomeClass();
c = new CSomeClass();
What happens when I reassign the valiable to new instance? Will CSomeClass
self-delete itself at that point, or when application terminates?
Lisa Tag: overload "A<int>"?? Tag: 282765
About list::sort() in STL
HI,
I have a problem about list::sort() in STL (I use Visual C++ 6.0).
Here is a simple example I test, which does not work.
#include <iostream>
#includer<list>
using namespace std;
int main()
{
list<long> L;
for (long i=1;i<=479250; i++)
L.push_back(i);
cout<< L.size()<<endl; // give 479250
L.sort();
cout<< L.size() << endl; // give 20498;???
return 0;
}
Anyone can give me suggestion? Thanks,
ucb Tag: overload "A<int>"?? Tag: 282761
Call unmanaged DLL (VS7.0) from VS6.0
Hello newsgroup,
I have to make a confession first: Yes, I'm still using VC6.0 (don't bother
telling me that I should download the 'free' 200* Express Edition, as I want to
use MFC).
Is it possible to call code from an unmanaged Dll written in VS 200[2|3|5] from
VS 6.0 code? AFAIK, MS only changed the way how debug information are stored
inside static libraries, but this shouldn't affect Dlls. To re-phrase the
question: Has the binary layout of classes/structs changed from VS6.0 to VS 200*?
Thanks in advance,
Stuart Tag: overload "A<int>"?? Tag: 282734
Why does this cause "data abort" ?
Hi imagine construction like below:
class CSomeWnd
{
public:
int m_hWnd;
virtual LRESULT SomeWndProc(HWND hWnd, MSG msg, WPARAM wParam, LPARAM
lParam);
}
CSomeWnd* g_pSomeWnd = new CSomeWnd();
g_pSomeWnd->CreateWindow( ... );
...
LRESULT GlobalWndProc(HWND hWnd, MSG msg, WPARAM wParam, LPARAM lParam)
{
return g_pSomeWnd->SomeWndProc(hWnd,msg,lParam,wParam);
}
Since I can not register window class with a non-static windows procedure, I
can not use a non-static member functions.
So above the global static GlobalWndProc 'relays' the message to non-static
SomeWndProc, so that SomeWndProc can access member variables easily.
However, the above construction causes data abort exceptions. I don't
understand why, but it's resolved by something like this:
CSomeWnd* g_pSomeWnd = new CSomeWnd();
g_pSomeWnd->CreateWindow( ... );
SetWindowLong(g_pSomeWnd->GetSafeHwnd(), GWL_USERDATA, (LONG) this);
LRESULT GlobalWndProc(HWND hWnd, MSG msg, WPARAM wParam, LPARAM lParam)
{
CSomeWnd* pWnd = (CSomeWnd*) GetWindowLong(hWnd, GWL_USERDATA);
return pWnd->SomeWndProc(hWnd,msg,lParam,wParam);
}
Can someone explain why this is?
And.. is there a better way to implement the above? some pattern?
Thanks,
Lisa Tag: overload "A<int>"?? Tag: 282724
exception handler type match in VC8
Could someone please explain how type matching is handled by multiple
catch clauses? Where is the type information stored? I know exeption
handling does not use RTTI, but how is it done? Thanks. Tag: overload "A<int>"?? Tag: 282718
Volume Shadow Copy - BackupComplete and VSS_E_BAD_STATE
Hello!
I'm using and testing VSS both on Xp and 2003. I use
CreateVSSBackupComponents();
InitializeForBackup();
SetBackupState();
GatherWriterMetadata();
StartSnapshotSet();
AddToSnapshotSet();
PrepareForBackup();
DoSnapshotSet();
GetSnapshotProperties();
VssFreeSnapshotProperties();
BackupComplete();
Every function works well on 2003. On XP all funcions work OK but
BackupComplete returns always VSS_E_BAD_STATE even when the files are
succesfully copied. (using every posible installed writer). This has
been tested on different XP machines and differents Service packs /
patchs to exclude some bad VSS installation or something.... Anybody
experimenting the same problem? Tag: overload "A<int>"?? Tag: 282702
function can't change a pointer's address
I've suddenly become quite stupid.
I'm passing a pointer to a function that can't change the pointer's address.
Can someone tell me why this is happening?
//I have a list of cGroup objects that I access using pointers
cGroup *pg;
pg=GetGroup(editPoly); //just returns a pointer to the group a polygon
belongs to
ChooseGroup(pg); //opens a dialog that displays the current group
and allows you to choose another group
//When ChooseGroup() returns pg hasn't changed!
cGroup *ChooseGroup(cGroup *pg){
INT_PTR ret;
if(ret=DialogBoxParam((HINSTANCE)ghInstance,
MAKEINTRESOURCE(IDD_CHOOSEGROUP),
ghWnd,(DLGPROC)ChooseGroupProc,
(LPARAM)pg)) //pg is passed here
just to display the current group in the dialog box
{
//at this point pg's address is the same as was passed in the
argument list
//and it is the same as it was before calling this function
pg=DlgGroup; //cGroup *DlgGroup is a file scope variable used to
record the choice of group in ChooseGroupProc
return pg; //pg's address has changed here but returns to
it's previous address after exiting the function.
}
else
return 0;
}
I thought I understood this stuff but it looks as though a few brain cells
have gone missing.
This should be simple but I can't see it.
Regards,
Ron Francis
www.RonaldFrancis.com Tag: overload "A<int>"?? Tag: 282699
Apology to Jeff Relf
Although there are still some things about Jeff Relf that annoy me ;), I
would like to offer my sincere apology for accusing him of impolite
behavior. It turns out that my newsreader has a configuration option to
cause a change in subject line to be treated like a new thread, and the
default was set the wrong way.
He was right, I was wrong.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc. Tag: overload "A<int>"?? Tag: 282693
Can I get some code executed while pre-compile?
Hi, I have some code like this:
if ( a < 99999 ) {
do_something();
}
Is there some way to modify it like this:
#define NUMBER_OF_9 5
if ( a < (power(10,NUMBER_OF_9) - 1) ) {
do_something();
}
I need the power() function to be extended while pre-compile, and
generate code like the first peice for compiler.
Or, Is the complier smart enough to compute the exponent since the two
parameter are all const? Tag: overload "A<int>"?? Tag: 282688
Making this non-recursive
This is a multi-part message in MIME format.
--------------090505060907010303040009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Folks,
I am in short urgent timeline to get this completed and I desperately
need a good student of C/C++ computer science to assist me here.
I recently found a stack overflow situation and need to correctly make
the following recursive code - non-recursive, specifically the
FindTreeRecord() function.
I attached findtree.cpp with the C/C++ source code. I wanted to attach
an example data file to work with, but it was too large for this post so
I made it available at:
http://beta.winserver.com/public/test/marshall.zip
The main() code has an example deep record to find in the qx file.
This HashTable code was designed back in 1996 by a former computer
science engineer no longer with us and I guess today with larger users,
with deeper nodes in the hash tree, the recursive nature of it is now
revealing the stack overflow problem.
The FindTreeRecord() is only used to clear specific nodes in the tree.
In the zip, this cut down version simply prints out the found node. But
in reality, it would clear the node and update the data file. IOW, the
true goal of the function is to "Clear" the node during an update process.
Some testing details:
The example record search shown in the main() code, should provide 4
hits, in an unknown order:
[filename]
[SYSTEM]
[ADDED]
[FILE]
If you explore this, you will see that I am passing the recursive level
so it is printed with each find. You will see it will go pretty deep
when a stack overflow occurs. If you put a limit like so in the
FindTreeRecord() function;
if (tr.Left && level<100)
FindTreeRecord(h, tr.Left, qxr, level+1);
if (tr.Right && level<100)
FindTreeRecord(h, tr.Right, qxr, level+1);
You will see that it might find some nodes but not all without the stack
problem.
The only issue I have is when traversing the tree recursively to find
all nodes with a specfic TQXRef value. I would greatly appreciate
assistance in making this function non-recursive.
Thanks in Advance
PS: I am going to switch to a SQL database system, but I need this fixed
now until the new SQL version is available.
--
HLS
--------------090505060907010303040009
Content-Type: text/plain;
name="findtree.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="findtree.cpp"
//
// File: findtree.cpp
// compile: cl findtree.cpp /W3 /GX /MD /D "_AFXDLL"
//
#include <stdio.h>
#include <afx.h>
#include <conio.h>
//---------------------------
// Hash Table
//---------------------------
const DWORD QXINDEX_MAXKEYLEN = 64;
const DWORD QXINDEX_HASHLIMIT = 4096;
const DWORD QXINDEX_LISTBLOCKSIZE = 16;
union TQXRef {
unsigned __int64 qword;
struct {
DWORD ref;
DWORD area;
} dword;
};
struct TListRecord {
DWORD Next;
TQXRef Ref;
};
struct TListBlock {
DWORD Next;
TQXRef Refs[QXINDEX_LISTBLOCKSIZE];
};
#pragma pack(1)
struct TTreeRecord {
DWORD Left;
DWORD Right;
TListRecord List;
BYTE KeyLen;
char Key[QXINDEX_MAXKEYLEN];
};
#pragma pack()
const char *qxfn = "marshall.qx";
DWORD HashTable[QXINDEX_HASHLIMIT] = {0};
//---------------------------
// Function Prototypes
//---------------------------
DWORD ReadAt(HANDLE &h, DWORD ofs, void *data, DWORD n);
DWORD WriteAt(HANDLE &h, DWORD ofs, const void *data, DWORD n);
BOOL FindTreeRecord(HANDLE &h, DWORD ofs, const TQXRef &qxr, int level);
BOOL FindRecord(HANDLE &h, const TQXRef &qxr);
BOOL FindRecord(HANDLE &h, const DWORD area, const DWORD ref);
HANDLE OpenQX(const char *fn);
BOOL CloseQX(HANDLE &h);
//---------------------------
// Main
//---------------------------
void main(char argc, char *argv[])
{
HANDLE hqx = OpenQX(qxfn);
if (hqx != INVALID_HANDLE_VALUE) {
try {
FindRecord(hqx,569, 1195264);
FindRecord(hqx,3, 10496);
} catch( ... ) {
printf("!! EXCEPTION: STACK OVERFLOW\n");
}
CloseQX(hqx);
}
}
DWORD ReadAt(HANDLE &h, DWORD ofs, void *data, DWORD n)
{
if (h == INVALID_HANDLE_VALUE) return 0;
DWORD cpos = SetFilePointer(h, ofs, NULL, FILE_BEGIN);
if (cpos != ofs) return 0;
DWORD z;
if (!ReadFile(h, data, n, &z, NULL)) {
return 0;
}
return z;
}
DWORD WriteAt(HANDLE &h, DWORD ofs, const void *data, DWORD n)
{
if (h == INVALID_HANDLE_VALUE) return 0;
SetFilePointer(h, ofs, NULL, FILE_BEGIN);
DWORD z;
if (!WriteFile(h, data, n, &z, NULL)) {
return 0;
}
if (z != n) {
return 0;
}
return z;
}
BOOL FindTreeRecord(HANDLE &h, DWORD ofs, const TQXRef &qxr, int level)
{
BOOL result = FALSE;
TTreeRecord tr;
if (ReadAt(h, ofs, &tr,sizeof(tr)) == 0) {
printf("! Error reading ofs: %d\n",ofs);
return 0;
}
if (tr.List.Ref.qword == qxr.qword) {
printf("# lvl: %3d a: %3d r: %7d [%s]\n",
level,
tr.List.Ref.dword.area,
tr.List.Ref.dword.ref,
tr.Key);
}
if (tr.List.Next) {
DWORD link = tr.List.Next;
while (link) {
TListBlock lb;
if (!ReadAt(h, link,&lb,sizeof(lb))) {
break;
}
for (DWORD i = 0; i < QXINDEX_LISTBLOCKSIZE; i++) {
if (qxr.qword ==lb.Refs[i].qword) {
printf("- lvl: %3d a: %3d r: %7d [%s]\n",
level,
lb.Refs[i].dword.area,
lb.Refs[i].dword.ref,
tr.Key);
}
}
link = lb.Next;
}
}
if (tr.Left) FindTreeRecord(h, tr.Left, qxr, level+1);
if (tr.Right) FindTreeRecord(h, tr.Right, qxr, level+1);
return TRUE;
}
BOOL FindRecord(HANDLE &h, const TQXRef &qxr)
{
if (ReadAt(h, 0,HashTable,sizeof(HashTable)) == 0) {
return FALSE;
}
for (DWORD i = 0; i < QXINDEX_HASHLIMIT; i++) {
DWORD ofs = HashTable[i];
if (ofs) FindTreeRecord(h, ofs, qxr, 0);
}
return TRUE;
}
BOOL FindRecord(HANDLE &h, const DWORD area, const DWORD ref)
{
TQXRef qxr;
qxr.dword.area = area;
qxr.dword.ref = ref;
return FindRecord(h,qxr);
}
HANDLE OpenQX(const char *fn)
{
HANDLE h = CreateFile(
fn,
GENERIC_READ|GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_RANDOM_ACCESS,
0);
int err = GetLastError();
if (h != INVALID_HANDLE_VALUE) {
ZeroMemory(&HashTable, sizeof(HashTable));
if (GetFileSize(h, NULL) != 0) {
ReadAt(h, 0, HashTable, sizeof(HashTable));
} else {
// initialize
WriteAt(h, 0, HashTable, sizeof(HashTable));
}
}
return h;
}
BOOL CloseQX(HANDLE &h)
{
if (h != INVALID_HANDLE_VALUE) {
return CloseHandle(h);
}
return FALSE;
}
--------------090505060907010303040009-- Tag: overload "A<int>"?? Tag: 282682
namespace std sort function not working
I can seem to get sort to work. I use the using namespace std at the
beginning of my program, and sort appears to be there, but when I compile my
program, it says sort is not a member of namespace std. I am tryint to use
sort to sort a CStringArray.
Z.K. Tag: overload "A<int>"?? Tag: 282680
unexpected public symbol in .obj for inlined function
Hello,
usually the compiler generates no symbol in the symbol table for an inlined
member.
inline int DerivedClass::function()
{
return 0;
}
But this is not the case in the following sample.
(See below).
where a public (external) symbol is generated.
A problem occurs when the above inline function is included in 2 independent
.cpp files and both .obj files are linked together (e.q. into a dll).
======== ExportTst1.cpp =======
class BaseClass
{
public:
virtual int function()
{
return 123;
}
};
class DerivedClass
: public BaseClass
{
public:
virtual inline int function();
};
template <class Base>
class TemplClass
: public DerivedClass
{
public:
int callFunction();
static inline Base & BaseOf(TemplClass<Base> const &);
static Base * b;
};
template <class Base>
Base * TemplClass<Base>::b = 0;
template <class Base>
int TemplClass<Base>::callFunction()
{
return BaseOf(*this).Base::function();
}
template <class Base>
inline Base & TemplClass<Base>::BaseOf(TemplClass<Base> const &)
{
return *b;
}
inline int DerivedClass::function()
{
return 0;
}
template TemplClass<DerivedClass>;
===============================
to compile:
cl -W4 -nologo -D__WINDOWS__ /LD -c ExportTst1.cpp
dumpbin /SYMBOLS ExportTst1.obj
in a VC++ 8.0 Session.
Note : The Problem flushes when the last statement
template TemplClass<DerivedClass>;
is removed. But i need the explizit template instantation. The original code
is splitted into multiple files (the inline function are in a .inl file,
the template functions are in a .c file, the classes/templates in a .hpp and
the templ. instance is a client.cpp file).
any ideas?
--
mit freundlichen Grüßen/best regards
mario semo Tag: overload "A<int>"?? Tag: 282679
mapped drives from service application in logon mode
Hi all,
How to access mapped drives along with local drives (like A:\, C:\, D:\,
X:\, Y:\ and Z:\) list from VC++ 6.0 service application in logon mode
without using password.
If the above is not possible, with password how to do?
I tried with ".\\username", "password" as 12th and 13th args of
CreateService API. But, It didn't get success. Service is not registering.
How to resolve this issue?
--
Thanks & Regards,
Alex. Tag: overload "A<int>"?? Tag: 282675
Programmatically find the MAC ID of a disabled NIC
HI all,
In my project, I need to find out the MAC ID of all the NICs,
including those which are disabled, on my system. How can I get this
information using C/C++ code? Is there an api call or a CRT function?
Can anyone help me please :) ?
Thanks in advance,
Shaji. Tag: overload "A<int>"?? Tag: 282674
Debug Global Objects
In VC++Express, can you debug (display) the contents of a static
global object within your current context, if you have not referenced
it? Tag: overload "A<int>"?? Tag: 282664
UTF-8 std::string to System::String^
Hi,
I have a std::string which I know is UTF-8 encoded. How can I make a
System::String^ from it?
I tried UTF8Encoding class, but it wants a Byte array, and I don't
know how to get that from a std::string.
Thanks for any help! Tag: overload "A<int>"?? Tag: 282653
Fatloss computer program
I have been using this computer program for a couple weeks now and i am very pleased with the results so far. its a software fatloss program, if your looking for a diet/weightloss plan i reccomend you check this place out first: http://fatloss9.50webs.com Tag: overload "A<int>"?? Tag: 282640
HP Desktop for sale!
Hi,
I have an unused HP Pavilion with the fallowing specs:
# Processor: AMD Athlon 64 X2 4000+ (2.1GHz, 2000MT/s System Bus)
# Memory: 2048MB PC2-5300 DDR2 SDRAM memory (2x1GB) (expandable to 8 GB (4 x 2 GB) (64-bit OS)/ 4 GB (4 x 1 GB) (32-bit OS))
# Hard Drive:320GB 7200RPM SATA 3G (3.0 Gb/sec) hard drive
# Optical Drive: 16X DVD(+/-)R/RW 12X RAM (+/-)R DL LightScribe SATA drive
# Expandable Drive Bay: HP Pocket Media Drive bay
# Video Graphics: Integrated graphics
# Network Interface: Integrated 10/100BaseT network interface
# Sound: High Definition 8-channel audio
# Fax/Modem: 56K bps data/fax modem
# Operating System: Genuine Windows Vista® Home Premium
This is "used" but basically brand new (it has literally been on for no more than 6 total hours..) is only 1 month old..
PRICE: $425 OBO
Email- pbdude911@yahoo.com Tag: overload "A<int>"?? Tag: 282637
Watch NFL Games Online
Watch NFL Games Online!
For every one who wants to watch the games online because they dont live in the teams town or are at work i found a site that has basically every game covered. Its perfect if you have afford a monthly $70 direct tv nfl access subscription. they got a bunch of channels
The sites http://nflonline.wizhoo.com Tag: overload "A<int>"?? Tag: 282635
Suggestions for a Rusty C++ Developer?
Hi,
I've been going mostly .NET and Java development for the past nine years,
with the last five focused on C#. I'd like to get my feet wet a bit with
Windows programming in C++, mainly to get a little more under the hood and
possibly to do some Windows Mobile development, most of which seems to be
geared around C++ (at least to do anything very useful). I took a semester of
C++ ("Introduction to Programming in C++) in college in 1998 and did well. On
a scale of one to ten, I'd consider myself probably an eight as far as C#
skills go. Does anyone have any suggestions about refreshers/tutorials (on
MSDN or otherwise) that I should check out? Something like "C++ for C#
developers" :-)
Thanks!
TWP Tag: overload "A<int>"?? Tag: 282632
Using thread synchronization
My scenario follows -
one thread fills a circular buffer and
some 5 other threads read the data.
The other details follows-
1. All threads operate independently.
2. Certain minimum and maximum difference limit the reading index of any
thread from the writing index. In other words, since the speed of all
threads are not similar the logic should limit the read index from the write
index by some minimum difference and also by some maximum one.
3. I uses critical sections to ensure exclusive access to the buffer and it
works fine.
4. I still have to use some synchronization mechanizm that controls the
indexing difference between read and write threads(as described in 2) but I
can't do it with Critical Section alone.
I'm stack with the question which and how mechanisms of thread
synchronization should I use(events, semaphores etc...)
Can someone advise pleas?
Regards
Mark Tag: overload "A<int>"?? Tag: 282631
Using a Windows DLL in Delphi
Hello!
Sorry for the (kind off OT), but I'm trying to translate the headers
for vssapi.dll to use the dll with Delphi. Almost everything is fine
and dandy, but when trying to use "CreateVssBackupComponents", I see
that the MSDN entry indicates that the function is exported as
"CreateVssBackupComponentsInternal". This is true in the Vista version
of the dll.
In older versions (Xp and 2003) the funnction was exported as
"?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" In
vista the function is ALSo present with that name.
Is it "safe" to use GetProcedure Address with that long name, seeing
that the name has not changes in all three versions (only a new alias
was added)? I know nobody can be 100% sure, but is this a safe guess?
Why are there a lot of exported function in this dll with those
unfriendly names? If not an API supposed to be clear? Tag: overload "A<int>"?? Tag: 282620
Link Error for Parent class's default copy constructor
I'm migrating VC++ 6.0 project to VC++ 2005 SP1 env and getting the linker
error. The DLL I'm building has many classes and about 3-4 level deep
hierarchy. The link error LNK2001 I get from a subclass's obj file is about
missing root classes's default copy constructor - BaseClass::BaseClass(class
BaseClass const &). No compiler error. Project compiles OK with VC++ 6.0.
Wondering if any one has any suggestion where to look for error. Tag: overload "A<int>"?? Tag: 282597
recognize .Net controls properly and get infos/styles/properties
In a Win32 project Is there a way to get infos/styles/properties
for .Net GUI controls ? When using Spy++ and pointing to a .Net
Checkbox (WindowsForms10.BUTTON.app.0.378734a) it return no styles
like BS_CHECKED, BS_RADIOBUTTON, BS_CHECKBOX,BS_GROUPBOX.
My application is similar to Spy++ ...how can I know if the window
WindowsForms10.BUTTON.app.0.378734a is a button, a checkbox or
something else?? How can I know the button state (Checked or not
checked) since there is no BS_CHECKED for a .NET control ???
When looking under the style tab of Spy++ for a .Net checkbox we can
see a 0000000B style (unknown style)....Maybe this will point to a
solution?
Is Win32 is appropriate appropriate to do a ".Net" spy++ ?? Is a
managed application will offers more information on .net controls?
Thanks, i really need help on this. Tag: overload "A<int>"?? Tag: 282594
Pimpl idiom without dynamic memory allocation
Hello!
I have just discovered a way to use the private implementation idiom
(pimpl), without the overhead of dynamic memory allocation. For those of
you who don't know what this is, Wikipedia has a nice article you can
read. Anyway, I discovered that if you make all members in the
implementation class mutable, you can in fact use this idiom without any
"unnecessary" memory allocation. Here's a minimal example of the method:
// In the header of your class called Line
#include <string>
class Line
{
public:
Line(const std::string& name);
const std::string& GetName() const;
void SetName(const std::string& s);
private:
// Private implementation idiom:
// all member variables are hidden in this class
class LineImpl;
const LineImpl& m_pimpl; // normally a non-const pointer
};
// and in your implementation file:
#include "Line.h"
// Here we define the class with the member variables
class Line::LineImpl
{
public:
LineImpl(const std::string& s) : m_s(s) {}
// all methods need to be const here
const std::string& GetName() const { return m_s; }
void SetName(const std::string& s) const { m_s = s; }
private:
mutable std::string m_s; // the trick! all members are mutable
};
// create the pimpl instance without using new
Line::Line(const std::string& s) : m_pimpl(LineImpl(s)) {}
// forward all member functions to the private implementation
const std::string& Line::GetName() const
{
return m_pimpl.GetName();
}
void Line::SetName(const std::string& s)
{
m_pimpl.SetName(s);
}
Ok experts, what do you all think? This method sacrifies
const-correctness for some extra speed. Is it worth it?
--
Daniel Tag: overload "A<int>"?? Tag: 282592
Specify Volume Serial Number when writing Joliet CD
Hi there,
I know this isn't a 100% relevant group, but unfortunately being palmed
onto the device.drivers forum resulted in me being palmed onto another
optical specialist MSN group which doesn't see much activity and hasn't
resulted in any replies as yet.
I'm writing a Data CD using IMAPI and would like to be able to force the
volume serial number to a specific value when burning, how can I achieve
this? Many thanks in advance.
Nick. Tag: overload "A<int>"?? Tag: 282583
Winsock select timeout
Hi,
i'm communicating with more than 40 serial devices connected thru' an
serial hub. the pc has to communicate thru' UDP to the serial hub.
since the response is quite sensitve, ( the application has to timeout
within 100msec) we are using "select" call with timeout.
There are around 100 threads that are parallely polling all the 40
devices on the serial hub.
I noticed that the select call is timingout i.e. returning 0
eventhough there is socket in the buffer..does this mean that the
timer got expired when that thread is in the sleep state (i.e. some
other thread is running) and later when the thread resumes, it is just
returning the previous state...
I'm running this application on a 2.66G Pentium PC..will the context
switching be an issue at all here. i dont see this problem if the
number of threads is reduced...,meaning less context switching.
thanks Tag: overload "A<int>"?? Tag: 282579
add application to firewall exception list on windows server 2003 Enterprise edition
Hi ,
I am trying to add my application in the windows firewall
exception list using vc++.I am using iNetFwMgr object to add
application in exceptionlist with coCreateInstance functions.
This works fine on windows XP and windows vista but when i am
running my application on windows server 2003 enterprise edition. it
is not adding my application in firewall exception list.
Can anybody help me for that?what could be the problem?
Regards,
R2. Tag: overload "A<int>"?? Tag: 282578
fonts related query
Hi,
Is there any way to read the font matrices such as font name, font
height, font height in twips from the font file?
Regards,
Ganesh Tag: overload "A<int>"?? Tag: 282574
create firewall interface "INetFwMgr interface" using CoCreateInstance failed on window server 2003
I am trying to create a interface of firewall using "INetFwMgr
interface" with CoCreateInstance function on window server 2003 but it
failed with give me error ERROR_SXS_KEY_NOT_FOUND
means. "The requested lookup key was not found in any active
activation context". i am not understand the what this error indicate,
where i am wrong... please help me..
But the same code is running fine on all other operating system like
xp, vista....
Code sample::
hr=CoCreateInstance(__uuidof(NetFwMgr),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(INetFwMgr),
(void **)&fwMgr);
create instance Failed with error ERROR_SXS_KEY_NOT_FOUND on window
server 2003...
If any idea then help me... Tag: overload "A<int>"?? Tag: 282568
How to get code page from current language input method?
Hi there,
In my application, I need to get the code page for current IME device. For
example, if user selected Chinese in language bar, and keyed in Chinese
characters, I need to get code page 936 so I could translate the got key
code, which is in unicode. into double byte character set. And if user uses
Polish input method, my application should get 1250 as the code page.
I am using _getmbcp() to get code page for current locale, but not accurate
if the locale is English, but user is inputting other languages.
Any idea how to get the code page?
Thanks lot, Tag: overload "A<int>"?? Tag: 282550
A solution to warning C4251 - class needs to have dll-interface...?
The following piece of code usually triggers warning C4251:
'MyClass::m_object' : class 'ThirdPartyTemplate<T>' needs to have
dll-interface to be used by clients of class 'MyClass':
template <typename T>
class ThirdPartyTemplate
{
public:
// Constructor.
ThirdPartyTemplate() {}
};
class __declspec(dllexport) MyClass
{
ThirdPartyTemplate<int> m_object; // warning C4251!
};
Is there really anything wrong about it? Here at LKEB (www.lkeb.nl), we
often get this kind of warning, when using Boost or STL. Now it appears
that one can get rid of the warning, by wrapping the ThirdPartyTemplate<int>
object inside a simple struct:
struct WrapperStruct
{
ThirdPartyTemplate<int> wrappedObject;
};
class __declspec(dllexport) MyClassWithoutWarning
{
WrapperStruct m_wrapper; // No warning! :-)
};
Does this approach really solve the problem, or does it only hide the
message?
Kind regards,
--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center Tag: overload "A<int>"?? Tag: 282546
__forceinline and SSE bug in VS2005?
At the bottom of this message is an example of what I believe is a bug
in the behavior of __forceinline when used with SSE intrinsics in
Visual Studio 2005. The summary is it seems that when __forceinline
is used on functions that contain SSE intrinsics, the functions are
not inlined after a very small depth (something under 10 levels of
functions). If __forceinline is replaced with __inline, the functions
are all inlined. From what I've read, there is no way __forceinline
should cause less inlining than __inline, but that's the behavior I'm
seeing. Also, if the SSE intrinsics are replaced with regular C, the
problem goes away as well.
I know the functions don't get inlined by warning 4714 which gets
raised on level 4 (not level 1 as MSDN seems to suggest), and by
examining the assembly which clearly shows function calls.
In the code below, the template parameter to the inlinetest function
determines how many levels of function calls there are before the call
to vset, which contains the SSE intrinsics. On my system, only very
small numbers (around 5) will successfully be inlined - there's some
ambiguity because the exact value has changed a few times and I'm not
sure why. Replacing __forceinline with __inline or changing vset to
not use intrinsics successfully inlines for much larger numbers (I've
tested with 100).
If anyone has any input on this problem - something I'm doing wrong or
ways to proceed, I'd appreciate it very much. Thanks,
-stephen diverdi
-stephen.diverdi@gmail.com
#include <stdio.h>
#include <intrin.h>
#define FORCEINLINE __forceinline
FORCEINLINE void vset ( float * const _a, float x )
{
#if 1
__m128 &a = *( __m128 * )_a;
a = _mm_set1_ps( x );
#else
for( int i = 0 ; i < 4 ; ++i )
_a[ i ] = x;
#endif
}
template < int N >
FORCEINLINE void inlinetest ( float * const a, int i )
{
return inlinetest< N - 1 >( a, i + 1 );
}
template < >
FORCEINLINE void inlinetest< 1 > ( float * const a, int i )
{
vset( a, ( float )i );
}
int main ()
{
float a[ 4 ];
inlinetest< 100 >( a, 0 );
fprintf( stderr, "%f\n", a[ 0 ] );
getc( stdin );
return 0;
} Tag: overload "A<int>"?? Tag: 282544
Writing to stdin inside an c commandline Application
Hello,
Does Anybody know (or has an idea) how to Write to stdin stream inside an c
Commandline Application?
I tried : fprintf( stdin, "STRING" );
which did not work (returned -1 ; error)
--
regards,
Gerd Keller Tag: overload "A<int>"?? Tag: 282543
typeid comparision does not work inside macro
I have two functions return a type_info. I used them to see if a class is of
a specifed type.
const type_info& MyOtherClass::desc()
{return typeid( MyOtherClass() );};
and
/*static*/const type_info& MyOtherClass::isA() const
{return typeid(*this);}
If i put them in the code straight up it works. I find that a class is of
the same knd as itself.
But if i put them in a macro the two return different typeIds for the same
class.
it worked perfect in VS.net (2002).
What im i missing??
I can supply a minimal project to show my problem.
/Matt Tag: overload "A<int>"?? Tag: 282541
Loading mulitple versions of a DLL
Hi all
I have a dll, the source code of which is in C++.
I want to be able to load two versions of the dll at the same time.
The second version of the dll has some changes to the C++ code.
I know that Windows does not allow loading mulitple versions of dlls
with the same name, so is there a work around? I know that the 'hacky'
way to get around this is to change the name of the dll. But I do not
want to do this. I was thinking of using assemblies, but I am not sure
how to create one. Does anyone know how to use assemblies or is there
something better?
Thanks in advance Tag: overload "A<int>"?? Tag: 282506
vs 8 bug ?
Hi Forum,
I have some disassembly to post which I think indicates a bug ... if not,
then hopefully one of the gurus here can tell me what I'm doing wrong ...
The scenario here is a .exe making a call to a __declspec( dllexport )
declared c function ... both projects are configured for _cdecl linkage ...
What follows are two dissambly blocks, the first with the ** alleged ** bug,
and the second with what seems to ** fix ** the alleged bug ...
------------------------ "bad" code block
------------------------------------------
pApuUpdateHWclock(fCurrentSimulationTime);
00401266 83 EC 08 sub esp,8
00401269 DD 45 A8 fld qword ptr [ebp-58h]
0040126C DD 1C 24 fstp qword ptr [esp]
0040126F FF 15 E8 D4 47 00 call dword ptr [_pApuUpdateHWclock
(47D4E8h)]
// __asm nop
_pApuFubar(x);
00401275 DD 45 E0 fld qword ptr [ebp-20h]
00401278 DD 1C 24 fstp qword ptr [esp]
.
.
.
--------------------------------"good" code block --------------------
pApuUpdateHWclock(fCurrentSimulationTime);
00401266 83 EC 08 sub esp,8
00401269 DD 45 A8 fld qword ptr [ebp-58h]
0040126C DD 1C 24 fstp qword ptr [esp]
0040126F FF 15 E8 D4 47 00 call dword ptr [_pApuUpdateHWclock
(47D4E8h)]
00401275 83 C4 08 add esp,8
__asm nop
00401278 90 nop
_pApuFubar(x);
00401279 83 EC 08 sub esp,8
0040127C DD 45 E0 fld qword ptr [ebp-20h]
.
.
.
---------------------------------------------------------------------------------------
So, obviously, inserting a nop into the instruction stream has "corrected"
the stack cleanup issue ...
What gives , gurus ?
Best Regards ,
gordon Tag: overload "A<int>"?? Tag: 282488
Only to overload a operater that exists is allowed.