CodePudding user response:
See the help file, remember where as seen, no check, forgive meCodePudding user response:
How to get the address of a string variable in the PBIn PB, often need to call some dynamic library (DLL) to realize the function expansion, but the DLL is usually written language or Delphi, C often
Will use a pointer, pointer parameter is often comes from the form, even though the PB can add REF keyword to indicate the delivery address is parameters, but the actual use of the
But often some unexpected results, I've been calling on a DLL, use the REF pass a string to DLL, but in the end the DLL is taken a series of
Noise, it's the wrong explanation to the address of the DLL, the DLL to other memory blocks of data, at this point, the PB can only hope to buy the needle,
In fact, in some cases, we are still able to use some other alternative way to insinuate operation pointer, below is my actual use by
Windows API to get to the address of the string methods:
Firstly, declare an API function:
The Function long lstrcpy (ref string Destination, ref string Source) library "kernel32. DLL" ALIAS FOR
"Lstrcpy; ANSI ";
Second, and then call the function to get the string above address:
String ls_src, ls_dst
Long ll_address
Ls_src="https://bbs.csdn.net/topics/PB" how to get the address of a string variable
Ls_dst=space (255)
Ll_address=lstrcpy (ls_dst ls_src)
So, get is the address of the string ls_dst ll_address, I have a C language to write a DLL, which is a function like this:
Void __stdcall ChangePrinterSetting (LPTSTR pCustomFormName, SIZEL * FormSize);
According to the normal way, in the PB should such statement and call:
The public FUNCTION Integer ChangePrinterSetting (REF string formName, REF STRU_SIZEL size) LIBRARY
"PrnSet. DLL" ALIAS FOR "ChangePrinterSetting; ANSI ";
String ls_fromName
STRU_SIZEL size;
Ls_fromName="my form format"
Cx=100000
the size.
Size. The cy=200000
ChangePrinterSetting ls_fromName, size ()
But such calls, actual operation found that the DLL is garbled, taken that the REF keyword passed to the parameters of the DLL address wrong, so I changed to such a party
Type:
The public FUNCTION Integer ChangePrinterSetting (long formName, REF STRU_SIZEL size) LIBRARY "PrnSet. DLL
"
ALIAS FOR "ChangePrinterSetting; ANSI ";
String ls_fromName, ls_temp
STRU_SIZEL size;
Ls_fromName="my form format"
Ls_temp=space (255)
Ll_address=lstrcpy (ls_temp ls_fromName)
Cx=100000
the size.
Size. The cy=200000
ChangePrinterSetting ll_address, size ()
In this way, he took to the correct Chinese string in a DLL, so how to write a few lines of code, save the parameters passed correctly, and also is no way to do something,
Always speaking, PB for rapid development of database application has its unique advantages, but encounter need to extend the functionality, with a third party language is
Ragged,
CodePudding user response:
Code,,,,CodePudding user response:
Learning, thank you for your offer,CodePudding user response:
To study theCodePudding user response:
Tell you to write an API:ULONG WINAPI getpointer (LPVOID Variable)
PB:
The function ulong getpointer (ref string s)...
The function ulong getpointer (ref char s)...
The function ulong getpointer (ref long s)...
.
Don't think you understand, look not to understand, don't ask for more,,,,
CodePudding user response:
Function body forget wrote:ULONG WINAPI getpointer (LPVOID Variable)
{
Return (ULONG) Variable;
}
CodePudding user response:
To study theCodePudding user response:
It seems is a profound problem.CodePudding user response:
Try ~ ~ ok `CodePudding user response:
Has a problem directly after looting new brother went, the brothers too much inventory, ha haCodePudding user response:
CodePudding user response: