473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# - calling Novell function (problem with variable types?)

Hello!

Can anyone help me with calling Novell function from dll?
I think my main problem is in translating C variable types to C# types.

Here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Globalization;

//declaring my class
public class IcNovell
{
[DllImport("calwin32.dll", CharSet = CharSet.Auto)]

public static extern int NWCallsInit(Byte reserved1, Byte
reserved2);

[DllImport("netwin32.dll", EntryPoint =
"NWDSCreateContextHandle", CharSet = CharSet.Auto, CallingConvention =
CallingConvention.Winapi, SetLastError = true)]

public static extern int GetHandle(out long context);

[DllImport("netwin32.dll", EntryPoint = "NWDSWhoAmI", CharSet =
CharSet.Auto, CallingConvention = CallingConvention.ThisCall,
SetLastError = true)]

public static extern int GetUser(long context, out string[]
NovellUserId);

}

//calling functions
// init
int cCode = IcNovell.NWCallsInit(0, 0);

long NovellContext = 0;
int RetCode0 = 0;
// get the context handle
RetCode0 = IcNovell.GetHandle(out NovellContext);
MessageBox.Show("RetCode0 is: " + RetCode0.ToString());
MessageBox.Show("Context is: "+NovellContext.ToString());
// my NovellContext equals 1 (looks good)

//string variable for user name
string[] NovellUserId = new string[255];
for (int i = 0; i < 255; i++)
{
NovellUserId[i] = " ";
}

int RetCode = 0;
// get the user name
RetCode = IcNovell.GetUser(NovellContext, out NovellUserId);
string hexValue = RetCode.ToString("X");
MessageBox.Show("RetCode is:" + hexValue);

At this point my RetCode is "FFFFFED1", which means (from Novell
documentation) "Trying to pass a bad context parameter to a NDS
function. Call NWDSCreateContextHandle first and use its return value as
the context parameter."
I think that variable NovellContext has wrong type (i got: long
NovellContext, maybe it should be IntPtr?).

In Novell documentation function declarations look like this:
NWDSCreateContextHandle
(http://developer.novell.com/ndk/doc/...7.html#sdk2687)
Syntax
C

#include <nwnet.h>
or
#include <nwdsdc.h>

N_EXTERN_LIBRARY (NWDSCCODE) NWDSCreateContextHandle (
NWDSContextHandle N_FAR *newHandle);

NWDSWhoAmI
(http://developer.novell.com/ndk/doc/...7.html#sdk2687)
Syntax
C

#include <nwnet.h>
or
#include <nwdsdsa.h>

N_EXTERN_LIBRARY (NWDSCCODE) NWDSWhoAmI (
NWDSContextHandle context,
pnstr8 objectName);
Any help will be appreciated.

Best regards,
Przemek
Dec 6 '05 #1
0 1931

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alex Lyman | last post by:
Does anyone have any code handy (or know what a good direction for me to head in), to call functions, if you have an address of the function, its declspec (for my app, it's limited to _stdcall and...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: komal | last post by:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function...
2
by: Joe | last post by:
I have 3 functions: ClientInfoA is doing something ClientInfoB is doing something SelectFunction2Run is a function to determine which function needed to run based on the value of the variable...
4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
2
by: 1388-2/HB | last post by:
On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: Nogema | last post by:
Hi everybody I use VB 2005 One of our project consisting in saving data on a network disk (NOVELL Sever) This project use windows authentification for each attempt to write on the disk,...
6
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.