How declare these methods in vc++ 
Author Message
 How declare these methods in vc++

The bellow function diclaration are in VB .how to declare these methods in
VC++ and How to use it.

Private Declare Function UuidCreate Lib "rpcrt4" (lpUUID As UUID) As Long
Private Declare Function UuidToString Lib "rpcrt4" Alias "UuidToStringA"
(lpUUID As UUID, lpUUIDString As Long) As Long
Private Declare Function RpcStringFree Lib "rpcrt4" Alias "RpcStringFreeA"
(lpUUIDString As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal
lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest
As Any, lpSource As Any, ByVal cBytes As Long)



Wed, 27 Oct 2004 14:38:23 GMT  
 How declare these methods in vc++
veeruchowdary

Please have a look in MSDN help for each of the functions you are interested in.

All of the functions are part of the Platform SDK collection.  You do not supply
the definitions for system api calls when programming in VC++ - rather you would
use the Visual Studio supplied header files.

The first three of your functions are declared in the header file "rpcdce.h"
The last two functions are declared in one of the windows header files, but is
generally included by referencing the standard windows include file
"windows.h"...

To demonstrate, I created a very simple console app, and the code that
demonstrates the use of the functions is:
/* ************************ */
char srcBuff[8000];
char destBuff[8000];

int main(int argc, char* argv[]){
UUID myUniqueId;
UuidCreate (&myUniqueId);
CopyMemory(destBuff,srcBuff,sizeof(srcBuff));
int x = lstrlen("this is a simple c string");
return 0;

Quote:
}

/* ************************ */

I used the defaults from the wizard generated project, that is the project uses
pch, and the stdafx.h file would look like this:

#define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include<windows.h>
#include<Rpc.h>
#include<Rpcdce.h>

The #define WIN32_LEAN_AND_MEAN  keeps the amount of stuff in the windows.h to a
minimum (minimizes chances for clashes and makes the first compile a bit
faster - otherwise not really necessary).  The #include<rpc.h> is necessary to
resolve declarations required in the #include <Rpcdce.h>

If you don't mind the extra baggage, you can remove the WIN32_LEAN_AND_MEAN
declaration, and simply include the windows.h, removing the two rpc headers.  In
other words, this works just as well in this case:

#include <stdio.h>
#include<windows.h>

This is some rather advanced stuff for C++ programmers -- you may want to
consider picking up a good book on Windows API C/C++ programming - a couple of
good authors to consider are Petzold and Ritcher (there are others that also do
a good job)

I hope this helps.

best regards
roy fine


Quote:
> The bellow function diclaration are in VB .how to declare these methods in
> VC++ and How to use it.

> Private Declare Function UuidCreate Lib "rpcrt4" (lpUUID As UUID) As Long
> Private Declare Function UuidToString Lib "rpcrt4" Alias "UuidToStringA"
> (lpUUID As UUID, lpUUIDString As Long) As Long
> Private Declare Function RpcStringFree Lib "rpcrt4" Alias "RpcStringFreeA"
> (lpUUIDString As Long) As Long
> Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal
> lpString As Long) As Long
> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest
> As Any, lpSource As Any, ByVal cBytes As Long)



Wed, 27 Oct 2004 22:17:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Can a method be declared inside another method?

2. How do you declare optiona method parameters in C#

3. Declaring statics variable in methods

4. Correct method of declaring an array argument

5. how to declare a method like this.

6. how to call a com method from vc++

7. How to export a class and/or methods in vc++ 5.0

8. How to export a class and/or methods in vc++ 5.0

9. Cant use VC ATL COM DLL method at VB project

10. Problem calling methods/catching events from WMP ActiveX 7.1 in VC++6.0

11. Transactions using CDatabase and ExecuteSQL Method in VC 4.2

12. Missing methods in vc ide

 

 
Powered by phpBB® Forum Software