|
DWORD vol;
waveOutGetVolume(0, &vol);
|
|
|
|
|
Hi,
I need to restrict some html files on my machine needs to be restricted before it open. So, I used Hook process and call Createprocess API, my application filter such html files and I put return TRUE. But it shows me error message as
---------------------------
C:\For Test Different Extensions\1.htm
---------------------------
Windows cannot find 'C:\For Test Different Extensions\1.htm'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search.
---------------------------
OK
---------------------------
If I put return FALSE, it shows me error messages as,
---------------------------
F:\differ ext\1.htm
---------------------------
There is not enough free memory to run this program. Quit one or more programs, and then try again.
---------------------------
OK
---------------------------
Let me know your ideas to quit those error messages.
My code is
DWORD WINAPI myCreateProcessW(
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
{
if (IsValidProcess == FALSE)
{
MessageBox (NULL,"ToughGuard Filter this Process","ToughGuard",MB_OK|MB_ICONINFORMATION|
MB_SETFOREGROUND|MB_TOPMOST);
return 0;
}
CreateProcessW( lpApplicationName, lpCommandLine,
lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags,
lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
}
Be simple and Be sample.
|
|
|
|
|
Hi,
I am guessing it is long file names... See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp
|
|
|
|
|
I have a menu with several items, one of which is a submenu. Normally, I use Class Wizard and ON_UPDATE_COMMAND_UI to enable or disable menu items.
But I'm not able to use the same technique to gray a submenu name itself because it doesn't have a command ID associated with it. Is it possible to gray a submenu item using MFC?
Mallikarjun Avanna Lavate
Mallikarjun Avanna Lavate
-- modat 6:34 Thursday 29th September, 2005
|
|
|
|
|
Greetings, everyone.
I stuck with an error "C2064: term does not evaluate to a function taking 1 arguments" when I try to pass pointer to class method as an argument to some method in template. Let's say I have a template with public method 'UserFunction' and private recursive method 'UserFunctionRecursive'
template <class TxData>
class CxTemplate {
public:
...
template <typename TxFunction>
void UserFunction(TxFunction pFunction) {
UserFunctionRecursive<TxFunction>(xData, pFunction);
}
...
private:
template <typename TxFunction4Recursion>
void UserFunctionRecursive(TxData xData, TxFunction4Recursion pFunction) {
if(bla-bla)
UserFunctionRecursive<TxFunction4Recursion>(xData, pFunction);
else
!!!!=> pFunction(xData);
}
} and I have a class which has user function and object of that template class
class CxClass {
public:
...
void Foo(int i) { ... }
CxTemplate<int> m_xObject;
} When I try to call 'UserFunction' method and pass Foo as an argument, I get the C2064 error (on line marked with !!!!=> above)
CxClass obj;
obj.m_xObject.UserFunction(CxClass::Foo); // error
and it's quite clear why, there is no instance of that function. So we have to make it static and it'll work. But, static function has no access to non-static members, so I can't make it static.
Any ideas how to make it work?
|
|
|
|
|
va`Lery wrote:
UserFunctionRecursive<txfunction>(xData, pFunction);
you need to call it like
UserFunctionRecursive(xData, pFunction) not UserFunctionRecursive<TxFunction>(xData, pFunction)
va`Lery wrote:
if(bla-bla) UserFunctionRecursive<TxFunction4Recursion>(xData, pFunction); else!!!!=> pFunction(xData);
make change like above
-- modified at 6:12 Thursday 29th September, 2005
|
|
|
|
|
Thanks for the suggestion, but it changes nothing.
The problem is that I can pass as an argument only static method or global function, and it works with the template I have. But, I need to pass pointer to method of existing instance of a class. That's where I'm lost.
|
|
|
|
|
ya you are right, lets wait for some expert for some help
|
|
|
|
|
I'm in no way an expert on templates, but since nobody else have found a solution I'll give it a try.
I don't see any place where you tell the compiler what TxFunction is to be instantiated to. To be a pointer to a CxClass member taking an int parameter returning void it should be
<br />
void (CxClass::*)(int)<br />
so perhaps you should call UserFunction as
<br />
obj.m_xObject.UserFunction<void (CxClass::*)(int)>(CxClass::Foo)<br />
(i would make a typedef of the member function pointer type!)
I haven't tried it so I have no idea if it will work.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
How can i get a refrence to the only created object of class X derived from CFormView?
I want to use public members of class X outside the class (from another CView derived class).
Thanks a lot
|
|
|
|
|
CMainFrame * fram=(CMainFrame*)AfxGetMainWnd()
CMyDocument *doc=fram->GetActiveDocument();
POSITION pos = doc->GetFirstViewPosition();
while (pos != NULL)
{
CMyScrolView* pView = doc->GetNextView(pos);
}
|
|
|
|
|
nothing got in my head can u write some words.
My application is a single document the splitter pane.
|
|
|
|
|
Allow me to elaborate:
CMainFrame * fram=(CMainFrame*)AfxGetMainWnd();
CMyDocument *doc=fram->GetActiveDocument();
POSITION pos = doc->GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = doc->GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CYourDerivedViewClass))) {
CYourDerivedViewClass* pYour = (CYourDerivedViewClass*)pView;
pYour->TheFunctionInQuestion();
}
}
But this makes your interface between the view classes dependent on implementation, and that's generally a bad idea. Instead I suggest you send private windows messages (or even registered ones) between you views. In CYourDerivedViewClass you can call the member function from the message handler, in this way the implementation stays in CYourDerivedViewClass. Much safer, much more clean.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-- modified at 9:07 Friday 30th September, 2005
|
|
|
|
|
What is virtual function? Where and how can i use this concept?
|
|
|
|
|
A virtual function is used when you use polymorphism. Let's take an example to make things clear.
Suppose you have two classes:
class Base<br />
{<br />
virtual void Test();<br />
}<br />
<br />
class Child : public Base<br />
{<br />
virtual void Test();<br />
}
So in this case, the Child class inherits from Base class. The Test function has been redefined in Child classes ans is virtual (you don't need to specify virtual again in the Child class).
Virtual functions are usefull when using pointers:
Base* pPtr = new Child;<br />
....<br />
....<br />
pPtr->Test();
In that case, even if the type of the object is CBase*, the funcion that will be called will be the one of the Child class. It is very usefull when you have different that inherits from the same base class. You can redefine in each a virtual function that will do something adapted for the class itself. Thus, you can store all these pointers in a table (containing pointers to the base class) and use their 'redefined' functions.
|
|
|
|
|
class A
{
virtual testA(){}
}
class B: public A
{
virtual testB(){}
}
B b;
the question is which is true below:
1. b has 1 vptr in its A sub object, the vtbl is enlarged from A's vtbl
2. b has 2 vptrs,one in A sub object, one in B sub object, vtbl maintains its size
-- modified at 5:15 Thursday 29th September, 2005
|
|
|
|
|
1 is correct. However, A's vtable and B's vtable are different, although in this case the first entry in both tables will be the same (&A:testA). The first four bytes (in VC++6.0 at least) of the classes are the vtable ptr; in A it will point to A's vtable, in B it will point to B's vtable. That's how an A-ptr pointing to a B-object will know how to call B's version of an overloaded virtual function and not A's version.
If we expand on your example so the definitions are:
class A
{
virtual testA();
testA2();
}
class B:public A
{
virtual testA();
virtual testB();
testA2();
testB2();
}
then the object layout and the results of calling the members will be:
A: vptr ---> &A::testA
B: vptr ---> &B::testA()
&B::testB()
A a;
B b;
A* ab=&b
a.testA()
a.testA2()
b.testA()
b.testA2()
b.testB()
b.testB2()
ab->testA()
ab->testA2()
ab->testB()
ab->testB2()
Hope this clarifies it.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
For C#, the declaration of the byte is as below:
public byte[] Header_byte = {0x10,0x00};
public byte[] DataLength_byte;
But I don't know how to declare bytes in visual c++
|
|
|
|
|
If you wan't bytes (8 bits), I suggest you use unsigned char
unsigned char Header_byte[] = {0x10,0x00};
unsigned char DataLength_byte[];
or
unsigned char *DataLength_byte;
|
|
|
|
|
When I use what you suggest,it got error below:
error C2146: syntax error : missing ';' before identifier 'Header_byte'
error C2377: 'byte' : redefinition;; typedef cannot be overloaded with any other symbol
fatal error C1004: unexpected end of file found
|
|
|
|
|
Hello. I just compiled it.
This works:
unsigned char Header_byte[] = {0x10,0x00};
unsigned char *DataLength_byte2;
This one doesn't due to "Unknown datasize":
unsigned char DataLength_byte[];
|
|
|
|
|
i give up... he'd better learn C++ first !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
read what the compilers tells you... it is clear enough.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
C# bytes are .NET framework type. C++ don't have them.
in C/C++, you can use char instead...
char Header_byte[] = {0x10, 0x00};
char DataLength_byte[];
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|