मेरे पास एक डेल्फी डीएलएल है जिसे मैंने नहीं लिखा था, लेकिन सी # एएसपी.नेट 3.5 ऐप से कॉल करने की आवश्यकता है।सी # से डेल्फी डीएलएल को कॉल करना अप्रत्याशित परिणाम उत्पन्न करता है
function CreateCode(SerialID : String;
StartDateOfYear, YearOfStartDate, YearOfEndDate, DatePeriod : Word;
CodeType,RecordNumber,StartHour,EndHour : Byte) : PChar;
external 'CreateCodeDLL.dll';
और यहाँ मेरी सी # कोड है:: यहाँ समारोह परिभाषा मैं डेवलपर्स से मिल गया है
[DllImport("CreateCodeDLL.dll",
CallingConvention = CallingConvention.StdCall,
CharSet=CharSet.Ansi)]
public static extern IntPtr CreateCode(string SerialID,
UInt16 StartDateOfYear,
UInt16 YearOfStartDate,
UInt16 YearOfEndDate,
UInt16 DatePeriod,
Byte CodeType,
Byte RecordNumber,
Byte StartHour,
Byte EndHour);
और अंत में, इस विधि के लिए अपने कॉल:
//The Inputs
String serialID = "92F00000B4FBE";
UInt16 StartDateOfYear = 20;
UInt16 YearOfStartDate = 2009;
UInt16 YearOfEndDate = 2009;
UInt16 DatePeriod = 7;
Byte CodeType = 1;
Byte RecordNumber = 0;
Byte StartHour = 15;
Byte EndHour = 14;
// The DLL call
IntPtr codePtr = CodeGenerator.CreateCode(serialID, StartDateOfYear,
YearOfStartDate, YearOfEndDate, DatePeriod, CodeType,
RecordNumber, StartHour, EndHour);
// Take the pointer and extract the code in a string
String code = Marshal.PtrToStringAnsi(codePtr);
हर बार मैं इस सटीक कोड को फिर से संकलित करता हूं और इसे चलाता हूं, यह एक अलग मूल्य देता है। अपेक्षित मूल्य 10 अंकों वाला कोड है जिसमें संख्याएं शामिल हैं। लौटा मूल्य वास्तव में 12 अंक है।
जानकारी का अंतिम महत्वपूर्ण भाग यह है कि मेरे पास एक परीक्षण है .EXE जिसमें एक जीयूआई है जो मुझे डीएलएल का परीक्षण करने की अनुमति देती है। .EXE का उपयोग करके प्रत्येक परीक्षण एक ही 10-अंकीय संख्या (अपेक्षित परिणाम) देता है।
तो, मुझे विश्वास करना है कि मैंने डीएलएल को गलत तरीके से कॉल किया है। विचार?
ध्यान दें कि "फास्टकॉल" का अर्थ विभिन्न संदर्भों में अलग-अलग चीजें हैं। माइक्रोसॉफ्ट का संस्करण Embarcadero के समान नहीं है, और मुझे संदेह है कि जीसीसी दोनों से अलग है। डेल्फी में, कॉलिंग सम्मेलन को "फास्टकॉल" भी नहीं कहा जाता है; यह "रजिस्टर" कॉलिंग सम्मेलन है। –