Click here to Skip to main content
15,912,756 members
Home / Discussions / C#
   

C#

 
AnswerRe: Printing and Formatting Pin
Michael Fritzius24-Sep-07 4:51
professionalMichael Fritzius24-Sep-07 4:51 
QuestionWindows Shutdown Pin
mobius11100121-Sep-07 5:56
mobius11100121-Sep-07 5:56 
AnswerRe: Windows Shutdown [modified] Pin
Anthony Mushrow21-Sep-07 6:21
professionalAnthony Mushrow21-Sep-07 6:21 
GeneralRe: Windows Shutdown Pin
Dave Kreskowiak21-Sep-07 6:36
mveDave Kreskowiak21-Sep-07 6:36 
GeneralRe: Windows Shutdown Pin
Anthony Mushrow21-Sep-07 6:48
professionalAnthony Mushrow21-Sep-07 6:48 
AnswerRe: Windows Shutdown Pin
Dave Kreskowiak21-Sep-07 6:34
mveDave Kreskowiak21-Sep-07 6:34 
AnswerRe: Windows Shutdown Pin
Matthew Cuba21-Sep-07 6:39
Matthew Cuba21-Sep-07 6:39 
QuestionArrhgg.. C++ DLLs make me angry.. [modified] Pin
Dio2221-Sep-07 5:40
Dio2221-Sep-07 5:40 
I need to make this DLL work Smile | :) Hopefully someone can help me.

The errors i'm getting are:

"Cannot find Entry Point.. "(unless I explicitly define the entry point as being #1)

If I explicitly define the entry point, I get the error:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Could it be because the function I'm calling calls other functions? If so, how do I fix that?


C++ DLL header..
<code>
extern "C" _declspec(dllexport) BOOL FindUser2(char *cpUserFile, 
              char *cpPassword, 
              char *cpUserName, 
              char *cpUserPriveledge, 
              char *cpUserID, 
              char *cpComments, 
              BOOL *bUserActive,
              char *cpErrorReason);
</code>




C++ DLL implementation..
(BOOL is an int)
<code>
extern "C" BOOL FindUser2(char *cpUserFile, 
              char *cpPassword, 
              char *cpUserName, 
              char *cpUserPriveledge, 
              char *cpUserID, 
              char *cpComments, 
              BOOL *bUserActive,
              char *cpErrorReason)
{
 ...
return TRUE;
}
</code>




C# definition
<code>
...
using System.Runtime.InteropServices;

namespace Material_OIT
{
    public static class Authorize
    {
        [DllImport("WN_USER_SECURITY.dll", EntryPoint="#1")]
        static public unsafe extern int FindUser2(ref char[] UserFile,
                                        ref char[] Password,
                                        out char[] UserName,
                                        out char[] UserPrivilege,
                                        out char[] userID,
                                        out char[] Comments,
                                        out int UserActive,
                                        out char[] ErrorReason);
    }
}
</code>





C# function call..
<code>

char[] UserFile = new char[256];
char[] Password = new char[256];
char[] UserName = new char[256];
char[] UserPriv = new char[256];
char[] UserID = new char[256];
char[] Comments = new char[256];
int UserActive = 0;
char[] ErrorReason = new char[256];

String userFile = @"C:\BSAH_WN\MATERIAL\CELL\FILES\CONFIG\USER_LIST.INF";
userFile.CopyTo(0, UserFile, 0, 51);
            
string password = "410572537";
password.CopyTo(0, Password, 0, 9);

Authorize.FindUser2(ref UserFile, ref Password, out UserName, out UserPriv, out UserID, out Comments, out UserActive,out ErrorReason);
</code>



-- modified at 13:46 Friday 21st September, 2007
AnswerRe: Arrhgg.. C++ DLLs make me angry.. Pin
Paul Conrad21-Sep-07 16:46
professionalPaul Conrad21-Sep-07 16:46 
GeneralRe: Arrhgg.. C++ DLLs make me angry.. Pin
Dio2221-Sep-07 17:16
Dio2221-Sep-07 17:16 
AnswerRe: Arrhgg.. C++ DLLs make me angry.. Pin
Paul Conrad22-Sep-07 4:58
professionalPaul Conrad22-Sep-07 4:58 
GeneralRe: Arrhgg.. C++ DLLs make me angry.. Pin
Dio2222-Sep-07 8:50
Dio2222-Sep-07 8:50 
QuestionOleDbConnection question Pin
ForkOffandDie21-Sep-07 4:37
ForkOffandDie21-Sep-07 4:37 
AnswerRe: OleDbConnection question Pin
Colin Angus Mackay21-Sep-07 5:01
Colin Angus Mackay21-Sep-07 5:01 
GeneralRe: OleDbConnection question Pin
ForkOffandDie21-Sep-07 5:05
ForkOffandDie21-Sep-07 5:05 
AnswerRe: OleDbConnection question Pin
Scott Dorman21-Sep-07 5:15
professionalScott Dorman21-Sep-07 5:15 
GeneralRe: How to use LoadFile method of RichTextbox ? Pin
nesaver8521-Sep-07 3:56
nesaver8521-Sep-07 3:56 
QuestionPrinttoprinter Pin
Saamir21-Sep-07 3:49
Saamir21-Sep-07 3:49 
AnswerRe: Printtoprinter Pin
Ravi Bhavnani21-Sep-07 3:59
professionalRavi Bhavnani21-Sep-07 3:59 
GeneralRe: Printtoprinter Pin
Saamir21-Sep-07 4:16
Saamir21-Sep-07 4:16 
Questionsaving graph as an xml file Pin
Mamphekgo Bahula21-Sep-07 3:25
Mamphekgo Bahula21-Sep-07 3:25 
AnswerRe: saving graph as an xml file Pin
Ravi Bhavnani21-Sep-07 4:01
professionalRavi Bhavnani21-Sep-07 4:01 
QuestionHow to use LoadFile method of RichTextbox ? Pin
nesaver8521-Sep-07 3:23
nesaver8521-Sep-07 3:23 
AnswerRe: How to use LoadFile method of RichTextbox ? Pin
Luc Pattyn21-Sep-07 3:45
sitebuilderLuc Pattyn21-Sep-07 3:45 
GeneralRe: How to use LoadFile method of RichTextbox ? Pin
nesaver8521-Sep-07 4:28
nesaver8521-Sep-07 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.