|
I poked around my registry and tried a bunch of right-clicks
on files of different types...I couldn't find any type that supported
any of those.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The next question is about catching all the SETTEXT message that are sent to a specific window:
I'm trying to hook all the settext messages that are sent to a specific window. The hook works almost perfectly, it intercepts all the settext messages and gets de windows handle stored in the pwp structure. pwp is a CWPRETSTRUCT type structure that contains the information of the SETTEXT hooked message.
The problem is that I can't get the text(caption) send to the window stored in the LPARAM of the settext hooked message (pwp->lParam. I only get garbage).
The idea is to get the text send to the window and save it to a file.
Im using a CallWndRetProc hook.
Here is my code.
LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)
{
TCHAR *a;
FILE *f1;
if(nCode < 0)
{
return CallNextHookEx(hook, nCode, wParam, lParam);
}
if (nCode == HC_ACTION)
{
CWPRETSTRUCT* pwp = (CWPRETSTRUCT*)lParam;
UINT message = pwp->message;
if (message == WM_SETTEXT)
{
unsigned int whandle = (unsigned int) pwp->hwnd;
// globalvar contains the
// (unsigned int)window's handle I want to catch.
if (whandle == globalvar)
{
LPARAM l = pwp->lParam;
// The problem is on the next line.
// Var a only gets garbage.
a = (TCHAR *) l
f1=fopen("c:\\hook.txt","a+");
fprintf(f1,"%d %s\n", whandle, a);
fclose(f1);
}
}
}
return CallNextHookEx(hook, nCode, wParam, lParam);
}
Ignacio Rivera
Mexico
|
|
|
|
|
Could it be possible that the WM_SETTEXT you get has been "POSTED" and the buffer lParam contains a pointer at has been destroyed by the time you get the hook-call?
AtomAnt
|
|
|
|
|
Hey Friends
I need to start an SDI Application (CFormView Based) Hidden
I do not want it to display main window first & then i cann showwindow(sw_hide)
In VC++ 6.0
I could do
....
AddDocTemplate(pDocTemplate);
m_nCmdShow =SW_HIDE;
...
but now in VS 2008
it does not works
Any clue?
|
|
|
|
|
Don't use the WS_VISIBLE style when creating the window?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks
will try
it is a single document interface type application
so will try with CMainFrame & CMyFormView
|
|
|
|
|
I need to compress a file programmatically without using any third party APPs but pure Win32/64 API or plain "C/C++". any one can help me?
Thank you masters!
|
|
|
|
|
Does this page [^] help?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No! Because it has not introduced any function or algorithm, moreover I think it's only about NTFS!
Any way! Thank you my master, CPallini
|
|
|
|
|
Jusef Marzbany wrote: No! Because it has not introduced any function or algorithm,
please elaborate.
Jusef Marzbany wrote: I think it's only about NTFS!
The requirements, from the documentation page I posted.
Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
<pre>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
|
Thank you very much Saurabh.Garg. Those are the exact things I needed.
Thank you just the same.
Thank you masters!
|
|
|
|
|
You are most welcome.
-Saurabh
|
|
|
|
|
I am working on a project, in C#. Due to security I decided to put some core services in a C DLL. I followed the example in the link:
How to create a DLL library in C and then use it with C#[^]
Now I want to use GetVolumeInformation in this dll. But I don't have any idea how to call it, what include are required etc.
Can anyone provide me help or link.
Thanks
|
|
|
|
|
logicon wrote: Now I want to use GetVolumeInformation in this dll. But I don't have any idea how to call it, what include are required etc
I suppose there is some documentation about [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes, I already visited that, simple C doesnot have those types. I a, good at C but no experience in Win programming in C
|
|
|
|
|
Well, I bet there is documentation also about those data types [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What I am trying to compile is :
#include <stdio.h>
#include <windows.h>
extern "C"
{
__declspec(dllexport) void DisplayHelloFromDLL()
{
char buffVN[512];
char buffSN[512];
char buffMCL[512];
char buffFSN[512];
char *v = "C:\\";
GetVolumeInformation(v, buffVN, 512, buffSN, buffMCL, 0x00000002, buffFSN, 512);
printf ("Serial Number [%s]\n", buffSN);
printf ("Hello from DLL !\n");
}
}
</windows.h></stdio.h>
I am getting error:
error C2664: 'GetVolumeInformationW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
|
|
|
|
|
|
Thanks.
I made a few changes, now its working
Thanks everyone else for reading and replying this thread!
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
extern "C"
{
__declspec(dllexport) void DisplayHelloFromDLL()
{
const TCHAR lpctstrRootPathName[] = _T("C:\\");
TCHAR tcVolumeName[MAX_PATH + 1];
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentLength;
DWORD dwFileSystemFlags;
TCHAR tcFileSystemNameBuffer[MAX_PATH + 1];
GetVolumeInformation(lpctstrRootPathName,
tcVolumeName,
MAX_PATH,
&dwVolumeSerialNumber,
&dwMaximumComponentLength,
&dwFileSystemFlags,
tcFileSystemNameBuffer,
MAX_PATH);
printf ("Serial Number [%u]\n", dwVolumeSerialNumber);
}
}
|
|
|
|
|
Cool
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
Your link was useful.
|
|
|
|
|
Hi,
in order to call native code (such as a C dll) from managed code (such as C#) you would
need P/Invoke technology. You will have to read up on it.
It starts with a using System.Runtime.InteropServices;
Then you must define the C# prototypes of the methods you are going to use, as in:
[DllImport("kernel32.dll")]
public static extern int GetDiskFreeSpaceEx(string rootPathName,
ref long lpFreeBytesAvailable, ref long lpTotalNumberOfBytes,
ref long lpTotalNumberOfFreeBytes);
and finally call them as if they were real C# methods.
That is, as long as the arguments have simple types such as int.
It becomes rather complex when structures and objects need being passed.
Read-only strings are just fine, writeable strings require a StringBuilder, etc.
Warning1: watch some size differences a long in C is an int in C#, a char in C# is a short in C, ...
Warning2: make sure to have the same calling conventions on both sides. (STDCALL, CDECL, ...)
I have some examples in some of my articles, see e.g. my timers article.
And there is a nice web site on method prototypes at www.pinvoke.net
|
|
|
|
|
Probably you have not read my question.
I want to use the API in C (not C#) code.
|
|
|
|