|
-
September 19th, 2001, 02:48 PM
#1
Re; Remote API calls with VB
I'm trying to use this rapi function to execute a dll on my remote machine. I've been able to run the dll with a C++ program but not with my VB program. I don't need to pass in any arguments its the matter of getting the return value from the dll in this pcbOutput variable. In C all I have to do is this:
DWORD cbOutput;
PBYTE pOutput;
HRESULT hres = CeRapiInvoke(L"\\FFX1\\HwRev", L"RaeGetHw", 0, 0, &cbOutput, &pOutput, NULL, 0);
But in VB I have this so far:
Declare Function CeRapiInvoke Lib "rapi.dll" ( _
byval pDllPath as string, _
byval pFunctionName as string, _
byval cbInput as Long, _
byval pInput as Byte, _
byval pcbOutput as Long, _
byval ppOutput as Byte, _
byval ppIRAPIStream as Long, _
byval dwReserved as Long) as Long
private Sub Command2_Click()
Dim lret as Long
Dim FilePath as string
Dim FileName as string
Dim ppOutput(100) as Byte
Dim pcbOutput as Long
Dim findData as CE_FIND_DATA
pcbOutput = 100
'Initialize RAPI
FileSelBackupCEInit
FilePath = "FFX1\HwRev.dll"
FileName = "RaeGetHw"
lret = CeFindFirstFile(FilePath, findData)
lret = CeRapiInvoke(FilePath, FileName, 0, 0, pcbOutput, ppOutput, 0, 0)
FileSelBackupCEUnInit
End Sub
any help would be trully appreciated
Thanks Drew A
-
September 19th, 2001, 02:56 PM
#2
Re: Re; Remote API calls with VB
Try passing ppOutput as the first element like:
lret = CeRapiInvoke(FilePath, FileName, 0, 0, pcbOutput, ppOutput(0), 0, 0)
let me know if it works!
-
September 19th, 2001, 04:12 PM
#3
Re: Re; Remote API calls with VB
I'm no longer getting any error messages but all I get in pcbOutput is 100 (the length of ppOutput). The result returned to lret is still a negative value indicating failure.
-
September 19th, 2001, 04:25 PM
#4
Re: Re; Remote API calls with VB
As soon as you call the function and get the return value, take a look at the Err object in the debugger and see what the value of Err.LastDLLError (or something like that)is, it'll help track down what the exact error is.
-
September 19th, 2001, 04:36 PM
#5
Re: Re; Remote API calls with VB
The error code is 87 which is ERROR_INVALID_PARAMETER
-
September 19th, 2001, 04:45 PM
#6
Re: Re; Remote API calls with VB
OK, I think I may see it now... the pInput will also need to be passed as a bytearray, try:
private Sub Command2_Click()
Dim lret as Long
Dim FilePath as string
Dim FileName as string
dim pcbInput as long
Dim ppInput(100) as byte
Dim ppOutput(100) as Byte
Dim pcbOutput as Long
Dim find
Data as CE_FIND_DATA
pcbInput = 100
pcbOutput = 100'Initialize RAPIFileSelBackupCEInitFilePath = "FFX1HwRev.dll"
FileName = "RaeGetHw"
lret = CeFindFirstFile(FilePath, findData)
lret = CeRapiInvoke(FilePath, FileName, pcbInput, pInput(0), pcbOutput, ppOutput(0), 0, 0)
FileSelBackupCEUnInit
End Sub
-
September 20th, 2001, 08:00 AM
#7
Re: Remote API calls with VB
I'm still getting the Error 87 code for Invalid Parameter. Is there anyway to figure out which argument type I'm failing on. I know with the C version of my program all I have to do is define the Output variables to capture the return value. Thanks for all of your help by the way DSJ. You seem to be the only one reading any of my questions.
-
September 20th, 2001, 08:18 AM
#8
Re: Re; Remote API calls with VB
Hi,
Quick comment ...
"\\FFX1\\HwRev.dll" is different of "FFX1\HwRev". They don't refer to the same place and one has an extension.
-
September 20th, 2001, 09:13 AM
#9
Re: Remote API calls with VB
The output arguments are explained like this in MSDEV:
pcbOutput :
[out] Pointer to a variable that is set to the number of bytes in the output buffer ppOutput when the function returns.
ppOutput :
[out] Pointer to a variable that is set to the location of the output buffer upon return.
-
September 20th, 2001, 09:18 AM
#10
Re: Re; Remote API calls with VB
I'm sure of the path name because of the CeFindFirstFile returns a valid handle to the file. But thanks anyway.
-
September 20th, 2001, 09:19 AM
#11
Re: Remote API calls with VB
Here is all of the information on this RAPI Function that I can find.
CeRapiInvoke
This function can be used as a general-purpose mechanism to remotely execute a routine on the Windows CE device.
HRESULT CeRapiInvoke(
LPCWSTR pDllPath,
LPCWSTR pFunctionName,
DWORD cbInput,
BYTE *pInput,
DWORD *pcbOutput,
BYTE **ppOutput,
IRAPIStream **ppIRAPIStream,
DWORD dwReserved);
Parameters
pDllPath
[in] Pointer to a buffer containing the name of a DLL on the Windows CE device containing pFunctionName.
pFunctionName
[in] Pointer to a buffer containing the name of the function that RAPI should call on the Windows CE device.
cbInput
[in] Number of bytes in the input buffer *pInput.
pInput
[in] Pointer to a buffer containing the input data.
pcbOutput
[out] Pointer to a variable that is set to the number of bytes in the output buffer ppOutput when the function returns.
ppOutput
[out] Pointer to a variable that is set to the location of the output buffer upon return.
ppIRAPIStream
[out] Pointer to a variable that is set to the address of the IRAPIStream interface.
dwReserved
Reserved.
Return Values
-
September 20th, 2001, 10:46 AM
#12
Re: Remote API calls with VB
Give this a shot...
private Sub Command2_Click()
Dim lret as Long
Dim FilePath as string
Dim FileName as string
dim pcbInput as long
Dim ppInput(100) as byte
Dim ppOutput as Byte
Dim pcbOutput as Long
Dim findData as CE_FIND_DATA
pcbInput = 100
RAPIFileSelBackupCEInitFilePath = "FFX1HwRev.dll"FileName = "RaeGetHw"
lret = CeFindFirstFile(FilePath, findData)
lret = CeRapiInvoke(FilePath, FileName, pcbInput, pInput(0), pcbOutput, ppOutput(0), 0, 0)
FileSelBackupCEUnInit
End Sub
-
September 20th, 2001, 11:11 AM
#13
Re: Remote API calls with VB
Without ppOutput(100) As Byte I keep getting an expected array error and without the (0) in front of ppOutput in the CeRapiInvoke statement I just get the same Error 87. I think the major problem is the fact that these 2 output variables are not being implemented correctly they are defined as follows:
pcbOutput
[out] Pointer to a variable that is set to the number of bytes in the output buffer ppOutput when the function returns.
ppOutput
[out] Pointer to a variable that is set to the location of the output buffer upon return.
Again thanks for all of your help in this
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|