c#


Can anyone find equivalent c# code


i need equivalent c# code
VssSdkClientId VSS_SDK_SPEC startVssSdkClientEcho(const VssSdkXChar *host,
const VssSdkPort port,
NotifyFunc &notifyFunc,
const eProtocolType protocolType,
bool doIcmpEchoRequest = true );
this is my c++ SDK code .... here i need to import this interface and need to perform some operation
[DllImport("VssSdkd")]
public static extern void startVssSdkClientEcho(StringBuilder IpAddress, long port, ? ,eProtocolType proType, bool Req);
NotifyFunc &notifyFunc -> here i need to implemet the some callback function it should call the function like
myNotifyFunc( enumType notificationType, void *data)
{
}
in c# "void *data" is not avalable how can achive this... hepl me guys... thanks in advance
For a call back function you can pass in a reference to a delegate and P/Invoke will marshal the callback to your delegate. See the this example.
For the void* parameter that would be best translated to an IntPtr which is always the same size as a pointer. If you need to retrieve the data from that pointer you can use one of the methods in System.Runtime.InteropServices.Marshal.
So for your example:
public delegate void NotifyFunc(enumType notificationType, IntPtr data);
[DllImport("VssSdkd")]
public static extern void startVssSdkClientEcho(string IpAddress,
long port, NotifyFunc notifyFunc, eProtocolType proType, bool Req);
Note that IpAddress can be a string. It would only have to be a StringBuilder if the calling code modified it and passed it back. Since the C++ prototype lists it as a const char*, it won't be changing the string.
I'm no expert when it comes to C++ interop, so I can't answer your question directly. However, I suggest you have a look at pinvoke.net. There are lots of examples of the correct way to use the Windows API from managed code. That may be enough information to help you figure out what would be appropriate for your function.

Related Links

How to Save contents of a textbox to a file
Managing Arrays in C# (Memory management)
ASP.NET Web API: any downsides to asynchronous operations?
Use Debug.Log from C++
Comparing only time element with Oracle db using Entity Framework
WebAPI - return file and additional data
Get RMS from FFT
When Include() executing in Entity Framework?
How to save accesstoken to string from API (C# Xamarin Studio)
Why i'm getting exception out of memory when trying to display images in pictureBox?
.net Regex, striping a matching sequence out
UserControl can not use app resources by default
GridView Asp .Net-Changing the selected value of a second drop down list based on value of first drop Down in same column
How to change endpoint binding type when dynamic hosting?
How do document service responses in ServiceStack with Servicestack swagger-api (1.2)
How to instantiate 3 gameobjects in 3 positions of a list of 20 random positions

Categories

HOME
ssms
virtual-machine
cors
c++builder
django-middleware
magento-1.9.2.1
bitbucket
artifactory
psexec
doctrine2
pyodbc
velocity
mbed
swift3.1
lambda-calculus
internet-explorer-7
project-structure
openoffice-basic
lotusscript
typeclass
spring-oauth2
unity3d-5
pyenv
jibx
pygraphviz
ninja-forms
keychain
google-cloud-powershell
aspnetboilerplate
contenteditable
nshttpurlresponse
codepen
inner-join
rivets.js
remap
react.rb
spring-cloud-bus
visio-2010
perldoc
bioperl
jenkins-docker
r-commander
lattice
alarmmanager
class-design
networkstream
netlink
jigsaw
key-value-store
git-cherry-pick
change-password
sprockets
mrunit
phpdesigner
markerspiderfier
wonderware
matlab-engine
magnet-uri
android-togglebutton
properties-file
firewire
genome
autopep8
nsmutableurlrequest
azure-worker-roles
visual-c#-express-2010
behance-api
visual-studio-setup-proje
hotlinking
node-mongodb-native
db2-connect
mobile-robots
static-class
zend-db-table
angularjs-select2
friendly-url
leap-year
exi
simplemembership
ftpwebrequest
auctex
blotter
boost.build
tasklist
aspmenu-control
beep
nsscrollview
norton
subdirectories
newspeak
web-widget
html-help-workshop

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App