Hello,
i wrote an dll (c )
im calling this dll in this way
CALL "@[DISPLAY]:X:/xxx/xxx/xxxx/xxxx/xxxxxx.dll"
MOVE ZEROES TO pValue
MOVE ZEROES TO CPOINT
CALL "@[DISPLAY]:function"
USING BY REFERENCE pValue
BY REFERENCE MyString
GIVING RETURN-CODE
END-CALL
Im getting the right return code but the variables pValue and MyString are empty.
So many questions need to be answered.
First, I assume you have gotten this to work locally?
What is the prototype of the C function? I assume it is something like:
extern int function(int *pi, char *str);
(Are you doing something to ensure you never overwrite the bounds of the str memory?)
Next, I assume that your COBOL variable pValue is a pointer to an integer type (based on the name)? And that MyString is a PIC X(n) variable, for some value of n?
Can you debug the DLL on the client side? And if so, can you set the passed variables before the CALL, and then see those set values in the DLL? That would confirm that you are actually passing the variables correctly.
Because it seems to me that, since the default call method of COBOL is to call by reference, and so you need to pass actual variables (and not pointers) to the CALL.
This should work, and you are probably doing something wrong. But without seeing a full example, I won't be able to say what that is.
So many questions need to be answered.
First, I assume you have gotten this to work locally?
What is the prototype of the C function? I assume it is something like:
extern int function(int *pi, char *str);
(Are you doing something to ensure you never overwrite the bounds of the str memory?)
Next, I assume that your COBOL variable pValue is a pointer to an integer type (based on the name)? And that MyString is a PIC X(n) variable, for some value of n?
Can you debug the DLL on the client side? And if so, can you set the passed variables before the CALL, and then see those set values in the DLL? That would confirm that you are actually passing the variables correctly.
Because it seems to me that, since the default call method of COBOL is to call by reference, and so you need to pass actual variables (and not pointers) to the CALL.
This should work, and you are probably doing something wrong. But without seeing a full example, I won't be able to say what that is.
Hello,
no pValue is a pic(X),
cobol variables:
77 pValue PIC X(254).
77 MyString PIC X.
i changed the data types very often but nothing helped.
I know im giving 2 variables and in the function is only one parameter but before i gave only one and i didnt workt either.
The dll function:
int pfadfinden(char* pValue)
{
size_t len;
_dupenv_s(&pValue, &len, "APPDATA");
std::string myString(pValue, len);
std::string myStringg(pValue, len);
LPWSTR ws = new wchar_t[myStringg.size() 1];
copy(myStringg.begin(), myStringg.end(), ws);
ws[myStringg.size()] = 0; // zero at the end
MessageBox(NULL, ws, L"Windows Tutorial", MB_ICONEXCLAMATION | MB_OK);
if(pValue != "0") {
return 76767676;
}
else
{
return 123321;
}
}
Hello,
no pValue is a pic(X),
cobol variables:
77 pValue PIC X(254).
77 MyString PIC X.
i changed the data types very often but nothing helped.
I know im giving 2 variables and in the function is only one parameter but before i gave only one and i didnt workt either.
The dll function:
int pfadfinden(char* pValue)
{
size_t len;
_dupenv_s(&pValue, &len, "APPDATA");
std::string myString(pValue, len);
std::string myStringg(pValue, len);
LPWSTR ws = new wchar_t[myStringg.size() 1];
copy(myStringg.begin(), myStringg.end(), ws);
ws[myStringg.size()] = 0; // zero at the end
MessageBox(NULL, ws, L"Windows Tutorial", MB_ICONEXCLAMATION | MB_OK);
if(pValue != "0") {
return 76767676;
}
else
{
return 123321;
}
}
I got this to work fairly easily. Here is my C function (using C syntax, not C ):
int pfadfinden(char *pValue)
{
GetEnvironmentVariableA("APPDATA", pValue, 200);
MessageBoxA(NULL, pValue, "Windows Tutorial", MB_ICONEXCLAMATION | MB_OK);
if (pValue != "0") {
return 76767676;
} else {
return 123321;
}
}
And here is my COBOL program:
identification division.
program-id. testit.
data division.
working-storage section.
77 pvalue pic x(254).
procedure division.
main-pgh.
call "@[DISPLAY]:testdll.dll"
move "Hello there" to pvalue
call "@[DISPLAY]:pfadfinden" using pvalue
display message pvalue
stop run
.
The C function shows a message box with the value of APPDATA, and that same value is shown in a message box from the COBOL program. The return value is 76767676.
I hope this helps.
I got this to work fairly easily. Here is my C function (using C syntax, not C ):
int pfadfinden(char *pValue)
{
GetEnvironmentVariableA("APPDATA", pValue, 200);
MessageBoxA(NULL, pValue, "Windows Tutorial", MB_ICONEXCLAMATION | MB_OK);
if (pValue != "0") {
return 76767676;
} else {
return 123321;
}
}
And here is my COBOL program:
identification division.
program-id. testit.
data division.
working-storage section.
77 pvalue pic x(254).
procedure division.
main-pgh.
call "@[DISPLAY]:testdll.dll"
move "Hello there" to pvalue
call "@[DISPLAY]:pfadfinden" using pvalue
display message pvalue
stop run
.
The C function shows a message box with the value of APPDATA, and that same value is shown in a message box from the COBOL program. The return value is 76767676.
I hope this helps.
Hey,
thank you for help. Now it works.
but now i have an other problem. The program works only if I run the program.
If an other person run the program an error occurs. "can't find Userpfad.dll".
The dll is in the same path. The path is also correctly.
Hey,
thank you for help. Now it works.
but now i have an other problem. The program works only if I run the program.
If an other person run the program an error occurs. "can't find Userpfad.dll".
The dll is in the same path. The path is also correctly.
Is Userpfad.dll actually located on the client machine? Or is Userpfad.dll located on some network shared drive? If it is on a network shared drive there maybe some permission issues. As you are using the @[DISPLAY]: syntax, you are using AcuConnect. What values have you set in the AcuConnect Access file? Try debugging acuthin ip-address -d alias. Or try starting AcuConnect with a trace file .. acurcl -start -t 7 -e mytrace. Have the other person launch your program acuthin ip-address alias. Go back and kill AcuConnect and open mytrace in an editor. That should help determine what is going wrong.