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

Lists permutations (unknown number) [duplicate]
Where constraint for simple types and string
MoqMockingKernel: System.TypeLoadException: Inheritance security rules violated by type
Custom app.config sections C#
Getting a PropertyGrid scrollbar to default back to the top when an item is selected
access and set variables in a class from another class
notify instances by events
Grid On Top Of A WINRT Media Element Causes Video To Be Blank
C# - splitting string of each value in an array
invoke matlab several times from .net
Listbox data binding with Viewmodel not showing up windows phone
how to remove cookies from browser in asp.net c#, SO answers NOT working
SQL CPU peaks with SqlDataAdapter.Fill Command
Webgrid: Maintain Filter after Sorting
Visual studio not copying content files from indirectly referenced project
How static scan all C# code for string format argument errors

Categories

HOME
algolia
leaflet
pyspark
grpc
nagios
x509certificate
coordinates
open-search-server
annyang
soap-client
ios-universal-links
adroitlogic
cakephp-2.0
fastreport
hql
android-actionbar
indri
scotty
udeploy
fibonacci
inline-assembly
adobe-captivate
osgi-bundle
paper-trail-gem
directions
oracle-nosql
offset
odp.net
wunderground
realloc
form-fields
motion
cowboy
azure-web-roles
jvisualvm
qt-quick
inner-join
encoder
text-formatting
g77
django-tables2
extjs3
bioperl
activesupport
richtext
alarmmanager
virtualenvwrapper
rowname
recurring
airwatch
treelist
pyshark
cascading
nonblocking
controlpanel
joomla3.3
perfect-scrollbar
alpha-beta-pruning
report-builder2.0
unityvs
sync
agent-based-modeling
hotlinking
jfilechooser
kendo-window
cab
infomaker
mmo
rbm
rfc822
invalidoperationexception
databus
certificate-revocation
event-propagation
joomla1.7
method-call
noise-reduction
mediastreamsource
simultaneous
ihtmldocument2

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