|
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.
|
|
|
|
|
I have to write a C++ code that computes the greatest common divisor of two numbers.
When Declaring x, y, temp, remainder as a Integer is this right? Or can someone help me in the right direction.
int x = 0;<br />
int y = 0;<br />
<br />
if (x < y) then<br />
<br />
cout << temp = x; <br />
cin >> x = y; <br />
cout << y = temp <br />
<br />
if else remainder = x % y
|
|
|
|
|
A recursive solution might look like:
int getGCD( int x, int y )
{
if (0 == y)
return x;
else
return getGCD(y, x % y);
}
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
<br />
int x = 0;<br />
int y = 0;<br />
int A = 0;<br />
int B = 0;<br />
int R = 0;<br />
<br />
Read x and y<br />
<br />
if (x >= y)<br />
{<br />
A = x;<br />
B = y;<br />
}<br />
else<br />
{<br />
A = y;<br />
B = x;<br />
}<br />
<br />
R = (A % B);<br />
<br />
while (R != 0)<br />
{<br />
A = B;<br />
B = R;<br />
R = (A % B);<br />
}<br />
<br />
Report "the GCD of x and y is B"<br />
Dave.
|
|
|
|
|
Hi all,
ColeDateTime m_starttime_ole,m_endtime_ole;
COleDateTimeSpan diff=(m_starttime_ole-m_endtime_ole);
int hour=(int)diff.GetTotalHours();
CString Value;
Value.Format(_T("%d"),hour);
AfxMessageBox(Value);
i m using this to get total hours.
it gives total hours 16,while actual total hours are 8.
please tell me correct way to calculate total hour diffrence between two timings.
please help me for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: it gives total hours 16...
Which is correct, since 2/3 of a 24-hour day is ~16 hours.
Now if you really wanted a difference of 8 hours, you need to set m_endtime_ole to be one day after m_starttime_ole . As it stands, they are the same day.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello every body
I've just down loaded visual studio 2008 C++ and is
only supports .NET. Is Microsoft hoping that the MFC with wither
and die.
Joe
|
|
|
|
|
If they did the same as they did for VC2005, the MFCs are not included in the express edition. You have to buy the standard edition in order to have the MFC's.
|
|
|
|
|
Jooooe wrote: Is Microsoft hoping that the MFC with wither
and die.
That has probably been the case since about 2002/2003. MFC still has a pulse but they have beaten it down pretty hard. We still use it for standalone apps as it has the most flexible structure and you get the sourcecode so you can tweak the MFC code out of tight spots.
If you buy the Professional Edition of Visual Studio 2008 and download the Visual C++ 2008 Feature Pack, you will find MFC has support for some new goodies like Office ribbons and the docking bars have gotten pretty advanced.
|
|
|
|
|
Jooooe wrote: Is the MFC dead
No its very healthy.
|
|
|
|
|
Jooooe wrote: Is the MFC dead
Nope. It is not free, however.
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]
|
|
|
|
|
Jooooe wrote: Hello every body
Hi Doctor Nick! (reference[^])
If MFC was dead they'd give it to you free in the download
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How to open excel file in Windows mobile MFC application??
|
|
|
|
|
I've installed several key-logger on my system one after the other (not at the same time ). Almost all have worked correctly except one thing!
when the user types something in Microsoft Office programs like MS Word, each single character is registerd several times in the log file! for example if the user has typed the word "Hello World!", it's registered as "HHHHHeeeeellllllllllooooo WWWWWooooorrrrrlllllddddd!!!!!". I've already tried to design my own key-logger! but the same problem occured.
Thank you masters!
modified on Saturday, November 8, 2008 3:16 AM
|
|
|
|
|
This is a stab in the dark, but I'm guessing by key logger you mean a keyboard hook, and that you are reporting both WM_KEYDOWN AND WM_KEYUP.
Iain.
|
|
|
|